链接自定义CSS来MVC6
问题描述:
Failed to load resource: the server responded with a status of 404 (Not Found)
我使用MVS 2015年的Web模式调试和我有链接自定义CSS来MVC6
app.UseStaticFiles();
,我使用常见的HTTP功能,因此出了什么问题?
答
您需要在您的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")
});
}
请提供错误请求的完整路径。您可能正在寻找错误位置的资源。再次,没有完整的跟踪,很难找出问题 – Saleem