c# - 404 error Localhost:8000 asp.Net -
if un-comment app.run(async (context) => ...
part of code can run html within code without issues. trying use index.html in wwwroot default. 404 error. how fix this?
using system; using system.collections.generic; using system.linq; using system.threading.tasks; using microsoft.aspnet.builder; using microsoft.aspnet.hosting; using microsoft.aspnet.http; using microsoft.extensions.dependencyinjection; namespace theworld { public class startup { public void configureservices(iservicecollection services) { } // method gets called runtime. use method configure http request pipeline. public void configure(iapplicationbuilder app) { // app.run(async (context) => //{ // var link = @"<!doctype html> // <html> // <head> // <title>test</title> // </head> // <body> // <h1>testfile</h1> // </body> // </html>"; // await context.response.writeasync(link); //}); } // entry point application. public static void main(string[] args) => webapplication.run<startup> (args); } }
you can use nuget-package microsoft.owin.staticfiles
, first thing in configure
write this:
app.usedefaultfiles(new defaultfilesoptions { defaultfilenames = new list<string>() { "index.html" } });
Comments
Post a Comment