2014-10-04 61 views
2

我託管我的網站博客上tumblr子域:服務包含從一個MVC/IIS Web應用程序

blog.withoomph.com

我已經修改爲主題的博客,我想使用我在我們主站點上使用的自己的字體。我試圖從獲得的字體:

beta.withoomph.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'因此不允許 訪問。

+0

我們可以看一些代碼嗎? – Mrchief 2014-10-04 15:42:29

+0

對不起,是一個可憐的quesiton,希望額外的信息使事情更清楚。 – jcvandan 2014-10-04 15:52:55

回答

7

出於安全原因,瀏覽器禁止呼叫位於當前原點之外的資源,因此您必須啓用跨源資源共享。將此添加到web.config

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

欲瞭解更多信息,請參閱this link

+0

奇妙的東西,就是我在找的東西。謝謝一堆! – jcvandan 2014-10-04 16:42:31

+2

請注意,允許'*'表示您接受任何人和每個人的請求,可能會讓您自己遭受跨站點腳本攻擊。 – Mrchief 2014-10-05 21:41:34

+0

是的,它可以改爲'value =「http://beta.withoomph.com」' – 2014-10-06 07:47:36

相關問題