.NET CORE项目设置起始页

把网页(例如index.html)放在wwwroot下(一定要放在wwwroot下),然后在Startup.cs文件的 public void Configure(IApplicationBuilder app, IHostingEnvironment env) 方法里添加下面两种方法中的一种即可

//1
DefaultFilesOptions defaultFilesOptions = new DefaultFilesOptions();
defaultFilesOptions.DefaultFileNames.Clear();
defaultFilesOptions.DefaultFileNames.Add("index.html");
app.UseDefaultFiles(defaultFilesOptions);
app.UseStaticFiles(); 

//或者

//2
FileServerOptions fileServerOptions = new FileServerOptions();
fileServerOptions.DefaultFilesOptions.DefaultFileNames.Clear();
fileServerOptions.DefaultFilesOptions.DefaultFileNames.Add("index.html");
app.UseFileServer(fileServerOptions);        

 

    原文作者:越来越胖的GuanRunwei
    原文地址: https://blog.csdn.net/qq_38890412/article/details/104240262
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞