1. 程式人生 > >解決用Asp.net Mvc 開發時出現glyphicons-halflings-regular.woff2 not found的問題

解決用Asp.net Mvc 開發時出現glyphicons-halflings-regular.woff2 not found的問題

這個問題要特別說明一點:不要用MVC中的捆綁(bundle)CSS檔案操作,否則,即使作一下配置,也沒有效果。

用Asp.net Mvc開發時,CSS用bootstrap的話,在引用字型時,會出現glyphicons-halflings-regular.woff2 not found的錯誤。雖不影響程式執行,但有個錯誤在那裡中感覺不舒服。這個問題出現的原因是IIS不知道.woff2的元型別。具體解決方法如下:

第一步:

在你專案的Web.config檔案中新增一些內容:

<system.webServer>...</modules><staticContent>
<remove fileExtension=".woff"/><mimeMap fileExtension=".woff" mimeType="application/x-font-woff"/><remove fileExtension=".woff2"/><mimeMap fileExtension=".woff2" mimeType="application/font-woff2"/></staticContent>
第二步:

在IIS伺服器上,進行如下操作:




按照圖片所示操作,OK問題解決。