2016-03-15 64 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