How to set start page in dotnet core web api?

后端 未结 9 582
广开言路
广开言路 2021-01-31 07:56

I try to build a web application with dotnet core web api,but i do not know how to set index.html as start page which can be done with dotnet framework web api easily. And i tri

相关标签:
9条回答
  • 2021-01-31 08:15

    For Asp.Net Core 2.0/2.1/2.2 just right click on Project → Properties → Debug and next to Launch Browser checkbox set path to the startup page you want.

    0 讨论(0)
  • 2021-01-31 08:20

    Your index.html file must be in the wwwroot folder

    wwwroot / index.html

    https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files

    0 讨论(0)
  • 2021-01-31 08:23

    If you are using a static file as the default page, the following code can help you.

     app.UseDefaultFiles(new DefaultFilesOptions { DefaultFileNames = new 
         List<string> { "index.html" } });
    

    If you are using the MVC view, just add the routing role.

    app.UseMvc(routes =>
       {
           routes.MapRoute(
               name: "default",
               template: "{controller=Home}/{action=Index}");
       });
    
    0 讨论(0)
提交回复
热议问题