,我發現了錯誤:ASP.net同源策略頭不起作用
XMLHttpRequest cannot load http://www.scirra.com/handlers/arcadeProcessScore.ashx. Origin http://static1.scirra.net is not allowed by Access-Control-Allow-Origin.
在arcadeProcessScore.ashx
我有臺詞:
public void ProcessRequest (HttpContext context) {
context.Response.AppendHeader("Access-Control-Allow-Origin", "http://static1.scirra.net");
context.Response.AppendHeader("Access-Control-Allow-Origin", "https://static1.scirra.net");
context.Response.ContentType = "text/plain";
然而,錯誤仍然存在。
我也試着簡單:
context.Response.AppendHeader("Access-Control-Allow-Origin", "*");
這也不起作用。
如果我在web.config
級別添加<add name="Access-Control-Allow-Origin" value="*"/>
它可行,但顯然不是解決方案。
我該如何讓arcadeProcessScore.ashx
接受static1.scirra.net
的請求?謝謝你的幫助。
工程很好,謝謝! IE限制是可以接受的。 – 2012-08-20 13:51:20
這是我解決我的問題的一部分。儘管我使用的代碼非常類似於此處列出的代碼,但Chrome仍在拋出原始問題。我的問題發生是因爲我的**代碼都設置了Access-Control-Allow-Origin頭文件**並且** 在我的網絡配置。一旦我從我的網頁配置中刪除了該行,我就開始運行了。 –
Garry
2012-12-19 00:53:32