jcv*_*dan 2 c# asp.net-mvc cors
我在tumblr上为我的网站托管博客:
blog.withoomph.com
我在博客上修改了主题,我想使用我在主站点上使用的自己的字体.我想从以下字体中获取字体:
beta.withoomph.com
但是,当页面尝试获取字体时,我收到CORS错误.这种情况最近才开始出现,因为它们可以毫无问题地获取.
有没有办法我可以设置IIS或我的MVC应用程序来将这些字体服务到子域?
编辑
对不起,我应该知道的比这更好.以下是一些更多信息:
这是获取网址的CSS:
@font-face {
font-family: 'avantgarde';
src: url('http://beta.withoomph.com/content/fonts/avant_garde.eot');
src: url('http://beta.withoomph.com/content/fonts/avant_garde.eot?#iefix') format('embedded-opentype'),
url('http://beta.withoomph.com/content/fonts/avant_garde.woff') format('woff'),
url('http://beta.withoomph.com/content/fonts/avant_garde.ttf') format('truetype'),
url('http://beta.withoomph.com/content/fonts/avant_garde.svg#avantgarde_bk_btdemi') format('svg');
font-weight: normal;
font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)
这是尝试获取字体时开发控制台中的错误:
来自" http://beta.withoomph.com "的字体已被跨源资源共享策略阻止加载:请求的资源上没有"Access-Control-Allow-Origin"标头.因此,不允许来源" http://blog.withoomph.com "访问.
出于安全原因,浏览器禁止调用驻留在当前源之外的资源,因此您必须启用跨源资源共享.将此添加到web.config.
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅此链接.
| 归档时间: |
|
| 查看次数: |
4092 次 |
| 最近记录: |