也许我只是醒了太多时间并完全监督了一些事情,但我正在使用MVC6 ASP.NET 5.0开发一个AngularJS网站.在我的wwwroot里面,我有一个index.html页面,它运行得很好,但随后应用了更新,现在突然间我只得到一个空白的白色屏幕:开发人员工具告诉我:
无法加载资源:服务器响应状态为404(未找到)
在我的创业公司里面我有以下内容:
public void Configure(IApplicationBuilder app) { app.UseDefaultFiles(new Microsoft.AspNet.StaticFiles.DefaultFilesOptions() { DefaultFileNames = new[] { "index.html" } }); app.UseMvc(); }
有些原因我在调试时仍然得到一个空白的白页,没有任何加载.
解决方法
您还必须指定app.UseStaticFiles().
From the docs:
In order for your Web app to serve a default page without the user having to fully qualify the URI,call the
UseDefaultFiles
extension method fromStartup.Configure
as follows. Note that you must still callUseStaticFiles
as well. This is becauseUseDefaultFiles
is a URL re-writer that doesn’t actually serve the file. You must still specify middleware (UseStaticFiles
,in this case) to serve the file.