Failed to load resource: the server responded with a status of 404 (Not Found)


我正在Web模式调试中使用MVS 2015,我有

  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")
    });
}

关于css - 将自定义CSS链接到MVC6,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36014242/

10-17 00:48