从MVC/IIS web应用程序向子域提供包含

本文关键字:包含 应用程序 MVC IIS web | 更新日期: 2023-09-27 18:25:36

我正在tumblr:上为我的网站托管博客

博客.withoumph.com

我已经修改了博客上的主题,我想使用我自己的字体,我在我们的主网站上使用。我正在尝试从以下位置获取字体:

beta.whithomph.com

然而,当页面试图获取字体时,我会遇到CORS错误。这是最近才开始的,因为它们过去是毫无问题的。

有没有一种方法可以设置IIS或MVC应用程序,将这些字体服务到子域?

编辑

对不起,我应该更清楚。以下是更多信息:

这是获取URL的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;
}

这是开发控制台在尝试获取字体时出现的错误:

来自原点的字体'http://beta.withoomph.com'已被阻止按跨来源资源共享策略加载:否请求的上存在"Access Control Allow Origin"标头资源原点'http://blog.withoomph.com因此不允许通道

从MVC/IIS web应用程序向子域提供包含

出于安全原因,浏览器禁止调用驻留在当前来源之外的资源,因此必须启用跨来源资源共享。将其添加到web.config

<configuration>
 <system.webServer>
   <httpProtocol>
     <customHeaders>
       <add name="Access-Control-Allow-Origin" value="*" />
     </customHeaders>
   </httpProtocol>
 </system.webServer>
</configuration>

有关详细信息,请参阅此链接。