将网站发布到Azure后自定义css字体显示

问题描述:

尝试在不同主机(somee.com,azure,localhost)上发布网站。网站在asp.net的MVC 4将网站发布到Azure后自定义css字体显示

在本地主机和somee.com显示: https://dl.dropboxusercontent.com/u/58930284/testing/font_local.png

在Azure的网站:
https://dl.dropboxusercontent.com/u/58930284/testing/font_azure.png

CSS:

@font-face 
{ 
    font-family: 'Font name'; 
    src: url("fonts/Font name.eot"); 
    src: url("fonts/Font name.eot?#iefix") format("embedded-opentype"), 
    url("fonts/Font name.woff") format("woff"), 
    url("fonts/Font name.ttf") format("truetype"), 
    url("fonts/Font name.svg") format("svg"); 
    font-weight: normal; 
    font-style: normal; 
} 

IIS 7不会返回未添加到的文件类型210元素或默认情况下在 元素中具有映射的元素。此行为可防止未经授权访问在IIS 7配置设置中没有映射的 文件。

基本上,IIS不会返回它不知道其媒体类型的静态文件。因此,您需要手动添加未知的MIME类型。

<configuration> 
    <system.webServer> 
     <staticContent> 
     <remove fileExtension=".svg" /> 
     <remove fileExtension=".eot" /> 
     <remove fileExtension=".woff" /> 
     <mimeMap fileExtension=".svg" mimeType="image/svg+xml" /> 
     <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" /> 
     <mimeMap fileExtension=".woff" mimeType="application/x-woff" /> 
     </staticContent> 
    </system.webServer> 
</configuration> 

将此配置放置到项目的webconfig文件中。