Setting index.html as default page in asp.net core

后端 未结 8 715
北荒
北荒 2020-12-30 19:17

How can I get asp.net core to serve an index.html file from inside my wwwroot?

The reason I want to do this is because I an developing an angular 4 app using the ang

8条回答
  •  悲哀的现实
    2020-12-30 19:34

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

    This is optimal since the UseDefaultFiles URL rewriter will only search for index.html, and not for the legacy files: default.htm, default.html, and index.htm.

    https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-2.2#serve-a-default-document

提交回复
热议问题