![](/img/trans.png)
[英]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.