Learning Visual Studios ASP.NET Application how do I attached html file to my project? in startup.cs
    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        **app.UseStaticFiles();**
    }
}
My index.html code
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Dutch Treat</title>
</head>
<body>
    <h1>Dutch Treat</h1>
</body>
</html>
The instructions say to move into wwwroot but there no wwwroot. Here a pic of what I have

It seems that you create project using a empty project template, like below.

It does help create ASP.NET Core project, not ASP.NET project. If you'd like to compare differences between them, you can check this doc:
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/choose-aspnet-framework?view=aspnetcore-5.0
How do I serve an html file in my Web App with ASP.NET without the WWWROOT?
As you shared in your code, calling the UseStaticFiles method in Startup.Configure, which enables static files to be served.
But please note that UseStaticFiles default to the file provider pointing at wwwroot, you can manually create the folder with name "wwwroot" and move index.html etc static files to it. Or create a folder with a name (such as "MyStaticFiles" etc) you expect, then configure static file serving from that folder, like below.
app.UseStaticFiles(new StaticFileOptions
{
    FileProvider = new PhysicalFileProvider(
        Path.Combine(env.ContentRootPath, "MyStaticFiles"))
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With