Asp.net-Mvc

如何刪除有關 glyphicons-halflings-regular.woff2 未找到的錯誤

  • August 30, 2015

ASP.NET MVC4 Bootstrap 3 應用程序從 Microsoft Visual Studio Express 2013 for Web IDE 執行。

Chrome 控制台總是顯示錯誤

http://localhost:52216/admin/fonts/glyphicons-halflings-regular.woff2
Failed to load resource: the server responded with a status of 404 (Not Found)

此文件存在於解決方案資源管理器的字型目錄中。建構操作設置為“內容”,複製到輸出目錄為“不要像在其他字型檔中一樣複製”。使用 NuGet 將 Bootstrap 3 添加到解決方案中。如何解決此問題,以免發生此錯誤?應用程序正確顯示 Glyphicon 和 FontAwesome 圖示。此錯誤總是在應用程序啟動時發生。

發生此問題是因為 IIS 不知道woffwoff2文件 mime 類型。

解決方案1:

在您的 web.config 項目中添加這些行:

<system.webServer>
 ...
 </modules>
   <staticContent>
     <remove fileExtension=".woff" />
     <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
     <remove fileExtension=".woff2" />
     <mimeMap fileExtension=".woff2" mimeType="font/woff2" />
   </staticContent>

解決方案2:

在 IIS 項目頁面上:

**第 1 步:**轉到您的項目 IIS 首頁並點兩下MIME Types按鈕:

第1步

**第 2 步:**點擊菜單中的Add按鈕Actions第2步

**第 3 步:**在螢幕中間出現一個視窗,在此視窗中您需要添加解決方案 1 中的兩行: 第 3 步

引用自:https://stackoverflow.com/questions/32300578