Fontawesome在IIS服务时不工作 [英] Fontawesome does not work when served by IIS

查看:140
本文介绍了Fontawesome在IIS服务时不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我将应用程式放在IIS7伺服器上时,FontAwesome不适用于我。



在Firefox中,要求的网址编码为 http: /l2etest.kema.intra/fonts/fontawesome-webfont.ttf%3Fv=4.0.3 ,我得到404.当我更改%3F $



同样的事情发生在IE中,但请求转到eot字体。 p>

这是我在CSS中的(与FontAwesome页面相同):

  @ font-face {
font-family:'FontAwesome';
src:url('../ fonts / fontawesome-webfont.eot?');
src:url('../ fonts / fontawesome-webfont.eot?#iefix& v = 4.0.3')format('embedded-opentype'),url('../ fonts / fontawesome-webfont .woff?v = 4.0.3')format('woff'),url('../ fonts / fontawesome-webfont.ttf?v = 4.0.3')format('truetype'),url /fonts/fontawesome-webfont.svg?v=4.0.3#fontawesomeregular')format('svg');
font-weight:normal;
font-style:normal;
}

我认为问题是IIS编码的URL,而不是请求 ../ fonts / fontawesome-webfont.eot?请求转到 ../ fonts / fontawesome-webfont.eot%3F



请不要建议从网址中删除?或#。他们有目的,是必要的。问题是如何使IIS不以这种方式对URL进行编码。任何线索都会感激。



编辑
Btw。上面的情况发生在web.config中设置requestValidationMode和requestPathInvalidCharacters:

 < httpRuntime shutdownTimeout =360maxRequestLength = 102400enable =truerequestValidationMode =2.0requestPathInvalidCharacters =/> 

没有它,我得到400(错误请求):



如何修复IIS以正确提供字体?



Edit2
确定,我找到问题的原因。 SquishIt捆绑工具MVC3正在改变这些字符。当我从包中排除font-awesome.css一切正常。

解决方案

SquishIt捆绑工具MVC3 url编码字体路径,因此在css文件中的 ../ fonts / fontawesome-webfont.eot?更改为 ../ fonts / fontawesome -webfont.eot%3F 。这通常返回400,因为%3F被认为不安全。如果你设置 requestPathInvalidCharacters =,则%3F被认为是安全的,但是显然没有文件`../ fonts / fontawesome-webfont.eot%3F` 404。



我从包中移除了fontawesome.css,一切正常。


FontAwesome does not work for me when I put my app on IIS7 server.

In Firefox the requested URL is encoded to http://l2etest.kema.intra/fonts/fontawesome-webfont.ttf%3Fv=4.0.3 and I get 404. When I change %3F to ? everything works fine.

Same thing happens in IE, but the request goes to eot font.

This is what I have in CSS (same as on FontAwesome page):

@font-face {
  font-family: 'FontAwesome';
  src: url('../fonts/fontawesome-webfont.eot?');
  src: url('../fonts/fontawesome-webfont.eot?#iefix&v=4.0.3') format('embedded-opentype'), url('../fonts/fontawesome-webfont.woff?v=4.0.3') format('woff'), url('../fonts/fontawesome-webfont.ttf?v=4.0.3') format('truetype'), url('../fonts/fontawesome-webfont.svg?v=4.0.3#fontawesomeregular') format('svg');
  font-weight: normal;
  font-style: normal;
}

I think the problem is that IIS encodes the URLs and instead of requesting ../fonts/fontawesome-webfont.eot? the request goes to ../fonts/fontawesome-webfont.eot%3F.

Please do not suggest removing '?' or '#' from the URLs. They are there on purpose and are essential. The question is how to make IIS not to encode the URLs in that way. Any clues will be appreciated.

Edit: Btw. the above situation takes place when in web.config I set requestValidationMode and requestPathInvalidCharacters:

<httpRuntime shutdownTimeout="360" maxRequestLength="102400" enable="true" requestValidationMode="2.0" requestPathInvalidCharacters="" />

Without it I get 400 (Bad request): A potentially dangerous Request.Path value was detected from the client (?)

How can I fix IIS to serve the font properly?

Edit2: OK, I found the cause of the problem. SquishIt bundling tool for MVC3 was changing those characters. When I exclude font-awesome.css from the bundle everything works fine.

解决方案

SquishIt bundling tool for MVC3 was url-encoding the font paths, so ../fonts/fontawesome-webfont.eot? in css file was changed to ../fonts/fontawesome-webfont.eot%3F. This normally returns 400, because %3F is considered unsafe. If you set requestPathInvalidCharacters="" then %3F is considered safe, but there is obviously no file ``../fonts/fontawesome-webfont.eot%3F`, therefore 404.

I removed fontawesome.css from the bundle and everything works fine.

这篇关于Fontawesome在IIS服务时不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆