有一個網站使用jquery在另一個域(Utlising CORS)上調用WCF Web服務。大多數方法都是GET方法,但有一些PUT方法。PUT HTTP/400請求Firefox/IE。適用於Chrome/Opera
所有的GET方法在所有瀏覽器上都能正常工作。 PUT方法但是隻適用於Chrome和Opera。對於Firefox和Internet Explorer,它們將導致HTTP 400 BAD REQUEST錯誤。我已經閱讀了所有內容,並試圖改變Web服務的CORS設置,但沒有成功。
如果瀏覽器在某些情況下完美工作而不是爲其他人完成工作,那麼瀏覽器如何進行這些PUT調用?
僅供參考,web服務Global.asax文件看起來像這樣:
protected void Application_BeginRequest(object sender, EventArgs e)
{
//CORS ENABLED
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
{
//These headers are handling the "pre-flight" OPTIONS call sent by the browser
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Authorization, Origin, Content-Type, Accept, X-Requested-With");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
HttpContext.Current.Response.End();
}
}
,並在web.config相關的會話是這樣的:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<httpProtocol>
</httpProtocol>
</system.webServer>
任何想法?
編輯:這是存在的jQuery請求:
addAbs = function addAbs() {
return $.ajax({
type: 'PUT',
url: Constructor.prototype.getServletURL(),
contentType: "application/json; charset=utf-8",
headers: {"Origin": "http://app-eservices.talentia-software.com"},
data: JSON.stringify(newAbsence),
timeout: GlobalContext.xhrTimeout,
beforeSend: self.showLoadingDialog('')
});
我們可以看到你的jQuery AJAX請求嗎? – MightyLampshade 2014-10-31 15:49:21
嗨,我很抱歉,慢回覆,更新線程與jQuery請求 – 2014-11-02 10:33:50