简体   繁体   English

服务包含来自MVC / IIS Web应用程序的子域

[英]Serving contain to sub domains from an MVC / IIS web application

I am hosting the blog for my site on tumblr: 我在tumblr上为我的网站托管博客:

blog.withoomph.com blog.withoomph.com

I have modified the theme on the blog and I want to use my own fonts that I use on our main site. 我在博客上修改了主题,我想使用我在主站点上使用的自己的字体。 I am trying to get the fonts from: 我想从以下字体中获取字体:

beta.withoomph.com beta.withoomph.com

However, when the page tries to fetch the fonts I am getting a CORS error. 但是,当页面尝试获取字体时,我收到CORS错误。 This only started hapenning recently, as they use to be fetched with no issues. 这种情况最近才开始出现,因为它们可以毫无问题地获取。

Is there a way I can set either IIS or my MVC app to service these fonts to sub domains? 有没有办法我可以设置IIS或我的MVC应用程序来将这些字体服务到子域?

Edit 编辑

Sorry, I should know better than that. 对不起,我应该知道的比这更好。 Here is some more information: 以下是一些更多信息:

This is the CSS to fetch the urls: 这是获取网址的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;
}

And this is the error in dev console when it tries to fetch the fonts: 这是尝试获取字体时开发控制台中的错误:

Font from origin ' http://beta.withoomph.com ' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. 来自“ http://beta.withoomph.com ”的字体已被跨源资源共享策略阻止加载:请求的资源上没有“Access-Control-Allow-Origin”标头。 Origin ' http://blog.withoomph.com ' is therefore not allowed access. 因此,不允许来源“ http://blog.withoomph.com ”访问。

For security reasons browsers prohibit calls to resources residing outside the current origin so you have to enable Cross-Origin Resource Sharing. 出于安全原因,浏览器禁止调用驻留在当前源之外的资源,因此您必须启用跨源资源共享。 add this to web.config . 将此添加到web.config

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

For more information see this link . 有关更多信息,请参阅此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM