Jquery NetworkError:Firefox中的REST服务中不允许使用405方法

Jquery NetworkError:Firefox中的REST服务中不允许使用405方法,jquery,ajax,rest,firefox,Jquery,Ajax,Rest,Firefox,我在jQueryAjax帖子中调用了REST服务。最初我得到网络错误:405方法不允许。但是,当我在Global.asax文件的应用程序_BeginRequest()中添加以下代码时,错误消失了,服务也没有被调用。它仍然在Firefox中显示选项http请求。为什么即使添加代码也会发生这种情况。 应用程序\u BeginRequest()代码 protected void Application_BeginRequest(object sender, EventArgs e) { HttpCon

我在jQueryAjax帖子中调用了REST服务。最初我得到网络错误:405方法不允许。但是,当我在Global.asax文件的应用程序_BeginRequest()中添加以下代码时,错误消失了,服务也没有被调用。它仍然在Firefox中显示选项http请求。为什么即使添加代码也会发生这种情况。

应用程序\u BeginRequest()代码

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,X-PINGOTHER Accept, x-requested-with");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
HttpContext.Current.Response.End();
}
}
接口

[ServiceContract]
public interface IService1{
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/TokenInsertion", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string UserdetailInsertion(UserInputParameters userInput);
}<br/>
var postCall = function () {
var input = {
AssociateRefId: "412", CpecialLoginId: "sdfa", PartnerId: "dfs", FirstName: "fdsf", LastName: "dfsr", Comments: "dsad", CreatedDate: "2013-02-15 15:54:10.130"
};
alert(JSON.stringify(input));
$.ajax({
type: "POST",
url: "http://localhost:45970/Service1.svc/TokenInsertion",
data: JSON.stringify(input),
contentType: "application/json",
dataType: "json",
success: function (response) {
alert(response);
},
error: function (xhr, status, error) {
alert(error);
alert(status);
}
});
}<br/>
jQuery Ajax

[ServiceContract]
public interface IService1{
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/TokenInsertion", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string UserdetailInsertion(UserInputParameters userInput);
}<br/>
var postCall = function () {
var input = {
AssociateRefId: "412", CpecialLoginId: "sdfa", PartnerId: "dfs", FirstName: "fdsf", LastName: "dfsr", Comments: "dsad", CreatedDate: "2013-02-15 15:54:10.130"
};
alert(JSON.stringify(input));
$.ajax({
type: "POST",
url: "http://localhost:45970/Service1.svc/TokenInsertion",
data: JSON.stringify(input),
contentType: "application/json",
dataType: "json",
success: function (response) {
alert(response);
},
error: function (xhr, status, error) {
alert(error);
alert(status);
}
});
}<br/>