[英]Method not allowed (http error 405) , wcf , rest service , post method
[英]Enable CORS on WCF Service. Get HTTP 405: Method Not Allowed
我正在嘗試在WCF服務上啟用CORS。 當我嘗試從客戶端發送請求時,該請求使用OPTIONS
動詞發送。 我總是收到HTTP 405: Method not allowed
錯誤
如果我嘗試使用Fiddler並使用POST
動詞創建相同的請求,則響應似乎是正確的。
我已嘗試在教程http://brockallen.com/2012/10/18/cors-iis-and-webdav/的幫助下刪除webDAV
,但它似乎不起作用。
我已經更新了我的WCF,以參考教程http://enable-cors.org/server_wcf.html啟用CORS。 我不確定出了什么問題。 該響應似乎具有CORS標頭
任何幫助將不勝感激。
PS:我不想讓這個問題變得很大而令人困惑。 如果您想查看我的配置,請告訴我,我可以分享
檢查此鏈接http://praneeth4victory.wordpress.com/2011/09/29/405-method-not-allowed/ :
protected void Application_BeginRequest(object sender, EventArgs e)
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
{
HttpContext.Current.Response.AddHeader("Cache-Control", "no-cache");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
HttpContext.Current.Response.End();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.