5

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'?

5

3 Answers 3

3

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

Sign up to request clarification or add additional context in comments.

Comments

1

As GrafiCode said. Create an empty ASP.Net website.

enter image description here

enter image description here

The image above shows how to create an empty ASP.Net website. Hope it helps you.

Comments

0

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.

3 Comments

What are views? At the moment I am just using the Chrome debugger, but I might want to go on to typescript.
@GeorgeKeeling Did you figure it out? I created empty ASP project. The server is starting and works properly but I don't see any "Views". Where do I put my Index.html and content files? I have an Installers libraries in C# and C# program that uploads installers through ftp and stores info in json files. I've wrote a simple page which read those files and displays list of installers that an user can download. This all works without a server-side code, without issues, but I just want to put this page in my Installers C# solution as I currently have this page on desktop :P
@pawcio yes I did figure it out as shown by my "whoo!" comment on Sep 3, 2022 at the top

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.