I want to play with javascript and html and a bit more and would like to do so in Visual Studio. There is a very similar question here. The solution says I can can create an empty ASP.Net Web site and use that. But I can't find a project template for an 'empty ASP.Net Web site'. The closest I get is 'ASP.net core empty project' and that uses c# and I can't see how to get my html and javascript involved. How can I get this 'empty ASP.Net Web site' or how can I use the 'ASP.net core empty project'?
-
1check this answer stackoverflow.com/a/58239052/5334486GrafiCode– GrafiCode2022-09-03 10:10:16 +00:00Commented Sep 3, 2022 at 10:10
-
1whoo! That worked and I've nearly got javascript debugging to work. Thanks!George Keeling– George Keeling2022-09-03 14:20:02 +00:00Commented Sep 3, 2022 at 14:20
-
alright then, I'm going to flag this as a duplicateGrafiCode– GrafiCode2022-09-03 16:22:18 +00:00Commented Sep 3, 2022 at 16:22
-
1Does this answer your question? How to create an ASP.NET website in Visual Studio 2019?GrafiCode– GrafiCode2022-09-03 16:22:40 +00:00Commented Sep 3, 2022 at 16:22
-
Yes, also useful, but I found all that easily after I had used your first comment and been to stackoverflow.com/a/58239052/5334486. Thanks againGeorge Keeling– George Keeling2022-09-04 13:43:55 +00:00Commented Sep 4, 2022 at 13:43
3 Answers
In VS 2022 empty ASP project will create following Porgram.cs:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", () => "Hello World!");
app.Run();
To run simple index.html page change this file to this:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.UseDefaultFiles();
app.UseStaticFiles();
app.Run();
Then create a wwwroot folder directly inside the project and put the index.html in this folder.
I've found above steps in this video
Comments
As GrafiCode said. Create an empty ASP.Net website.
The image above shows how to create an empty ASP.Net website. Hope it helps you.
Comments
ASP.Net always represents the backend, where your data come from and in "Views" you can just create normal html pages and of cause you can use Java script in there.
HomeController
public IActionResult Index()
{
return View();
}
And in Views you have a Index file in "Home". There you can start with your page, but data only comes from the C# code if you need data from the database.
But my recommendation would be, if you just want to use html and javascript. Install VS Code and javascript via nvm and create a file index.html.