我在使用网络字体的ASP MVC 4 .Net网站遇到了一个奇怪的问题。
该网站引用了FontAwesome和Roboto,并在FireFox,Chrome和IE10中按预期呈现,但也需要在IE8 +中工作。
值得注意的是,当本地保存html源代码时,它可以在IE8中运行,而不是在IIS返回时。
在IIS(7或在VS2010中的IIS Express中进行调试)提供服务时,似乎没有将.eot发送到浏览器。但是woff和ttf按预期返回(使用Fiddler和Firebug证实)。
我已经拥有:
mimeMap fileExtension =“。eot”mimeType =“application / vnd.ms-fontobject”/>在web.config。
为.css和字体文件设置“内容”的操作。
css @fontface声明为:
@font-face
{
font-family:'FontAwesome';
src:url('../font/fontawesome-webfont.eot?v=3.1.0');
src:url('../font/fontawesome-webfont.eot?#iefix&v=3.1.0') format('embedded-opentype'),
url('../font/fontawesome-webfont.woff?v=3.1.0') format('woff'),
url('../font/fontawesome-webfont.ttf?v=3.1.0') format('truetype'),
url('../font/fontawesome-webfont.svg#fontawesomeregular?v=3.1.0') format('svg');
font-weight:normal;font-style:normal
}
401:
HTTP/1.1 401 Unauthorized
Content-Type: text/html
Server: Microsoft-IIS/7.5
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
X-Powered-By: ASP.NET
Date: Wed, 16 Oct 2013 14:48:51 GMT
Content-Length: 1293
Proxy-Support: Session-Based-Authentication
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>401 - Unauthorized: Access is denied due to invalid credentials.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
<h2>401 - Unauthorized: Access is denied due to invalid credentials.</h2>
<h3>You do not have permission to view this directory or page using the credentials that you supplied.</h3>
</fieldset></div>
</div>
</body>
</html>
200:
HTTP/1.1 200 OK
Content-Type: application/vnd.ms-fontobject
Last-Modified: Tue, 13 Aug 2013 10:43:18 GMT
Accept-Ranges: bytes
ETag: "067e7eb1198ce1:0"
Server: Microsoft-IIS/7.5
Persistent-Auth: false
X-Powered-By: ASP.NET
WWW-Authenticate: Negotiate oYGgMIGdoAMKAQChCwYJKoZIgvcSAQICooGIBIGFYIGCBgkqhkiG9xIBAgICAG9zMHGgAwIBBaEDAgEPomUwY6ADAgEXolwEWl1ljYO00B8Uphl5NsfdQu3+5k9yJlSL2JTRqcofSeQ9oylbvSVbHKLWvBrFned5/+Sxodxe6MkY+IB0xEvtp3FVXB4HM3MuanzmqUo7p58L+wDxxG7hdnRgsA==
Date: Wed, 16 Oct 2013 15:36:17 GMT
Content-Length: 29360
�r���q����������������������LP�����������������������#M
�������������������F�o�n�t�A�w�e�s�o�m�e����R�e�g�u�l�a�r���$�V�e�r�s�i�o�n� �3�.�1�.�0� �2�0�1�3���&�F�o�n�t�A�w�e�s�o�m�e� �R�e�g�u�l�a�r�����BSGP�������������������q��q��e�����Y�D
M�F�x���>��ޝ��Ə)[1ɵH���-A)F��ٜ1��.�/
d�U'�&a