服务包括从一个MVC / IIS Web应用程序的子域 [英] Serving contain to sub domains from an MVC / IIS web application

查看:130
本文介绍了服务包括从一个MVC / IIS Web应用程序的子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我主持我的网站上tumblr的博客:

blog.withoomph.com

我已经修改的博客主题,我想用我自己的字体,我对我们的主要网站上使用。我想从得到的字体:

beta.withoomph.com

然而,当页面试图获取字体我得到一个CORS错误。这个最近才开始hapenning,因为它们使用要获取完全没问题。

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

修改

对不起,我应该知道比这更好的。下面是一些更多的信息:

这是抓取的网址的CSS:

  @字体面{
    FONT-FAMILY:'前卫';
    SRC:URL('http://beta.withoomph.com/content/fonts/avant_garde.eot');
    SRC:URL('http://beta.withoomph.com/content/fonts/avant_garde.eot?#iefix')格式(嵌入式OpenType字体),
         URL('http://beta.withoomph.com/content/fonts/avant_garde.woff')格式(WOFF),
         URL('http://beta.withoomph.com/content/fonts/avant_garde.ttf')格式(TrueType字体),
         URL('http://beta.withoomph.com/content/fonts/avant_garde.svg#avantgarde_bk_btdemi')格式('SVG');
    字体重量:正常;
    字体风格:正常;
}

这是当它试图获取字体在开发者控制台中的错误:


  

从原产字体' http://beta.withoomph.com '已经从封锁
  装载由跨来源资源共享政策:否
  访问控制允许来源标头present的要求
  资源。因此出身 http://blog.withoomph.com '是不允许的
  访问。



解决方案

出于安全原因禁止浏览器对驻留在当前原产地之外的,所以你必须启用跨来源资源共享的资源调用。它添加到的web.config

 <结构>
 < system.webServer>
   < httpProtocol>
     < customHeaders>
       <添加名称=访问控制允许来源VALUE =*/>
     < / customHeaders>
   < / httpProtocol>
 < /system.webServer>
< /结构>

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

I am hosting the blog for my site on tumblr:

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

However, when the page tries to fetch the fonts I am getting a CORS error. 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?

Edit

Sorry, I should know better than that. Here is some more information:

This is the CSS to fetch the urls:

@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. Origin 'http://blog.withoomph.com' is therefore not allowed access.

解决方案

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.

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

For more information see this link.

这篇关于服务包括从一个MVC / IIS Web应用程序的子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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