I am trying to enable CORS on a WCF service. When I try to send a request from my client, the request is sent using the OPTIONS
verb. I always get a HTTP 405: Method not allowed
error
If I try using Fiddler and create the same request with the POST
verb the response seems to be correct.
I have tried to remove webDAV
with the help of the tutorial http://brockallen.com/2012/10/18/cors-iis-and-webdav/ but it doesnt seem to work.
I have updated my WCF to enable CORS referring to the tutorial http://enable-cors.org/server_wcf.html . I am not sure what is going wrong. The response seem to have the CORS header
Any help would be highly appreciated.
PS: I did not want to make the question very big and confusing. If you would like to look at my config be let me know and I can share it
Check this link 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();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.