2016-03-15 60 views
0
Failed to load resource: the server responded with a status of 404 (Not Found) 

我使用MVS 2015年的Web模式调试和我有链接自定义CSS来MVC6

app.UseStaticFiles(); 

,我使用常见的HTTP功能,因此出了什么问题?

+0

请提供错误请求的完整路径。您可能正在寻找错误位置的资源。再次,没有完整的跟踪,很难找出问题 – Saleem

回答

3

您需要在您的project.json中有依赖关系。

"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final" 

注意:ASP.net MVC默认查看wwwroot文件夹中的静态内容。但是,如果要更改它,则需要将其覆盖为Startup.cs

var staticContentFolder = new DirectoryInfo(env.WebRootPath).Parent; 
if (staticContentFolder != null) 
{ 
    app.UseStaticFiles(new StaticFileOptions() 
    { 
     FileProvider = new PhysicalFileProvider(
      Path.Combine(staticContentFolder.FullName, "Contents")), 
     RequestPath = new PathString("/Contents") 
    }); 
} 
+0

我有它,否则它会显示一个错误,它不会编译 – ma1169

+0

默认情况下,服务器将查找“wwwroot”文件夹的静态文件。你在哪里存储你的静态文件? – Saleem

+0

谢谢你的解决方案... – ma1169