Ajax post HTML 405,ajax - 我的Web API的AJAX POST调用中出现405错误方法不允许 - 堆栈内存溢出...

我正在尝试通过AJAX POST调用来调用Web API函数,但始终收到405错误。 我一直在寻找,但一直在寻找说启用CORS的解决方案,但我没有这样做。 现在,我只是试图以html显示数据。 用户输入订单号,然后填写Web API函数的参数。 谁能告诉我怎么了?

我的Web API函数:

Public Function GetOrderContents(ByVal ordNbr As String) As SPFolderOver

Dim retValue As ReturnVal

retValue = GetOrderInformation(ordNbr)

Dim sp = New Sharepoint()

Dim t = sp.GetOrderContent(retValue.Year, retValue.SONumber)

Dim contentFolder = New SPFolderOver()

contentFolder = SPFolderOver.LoadFolder(t)

contentFolder.FolderName = t.FullPath

Return contentFolder

End Function

我的AJAX电话:

function GetOrder() {

var order = document.getElementById("orderNbr").value;

$.ajax({

cache: false,

type: "POST",

url: "http://localhost:54754/orders/{ordNbr}/contents",

data: { 'ordNbr': order },

success: function (data) {

$("#orderContents").html(data);

}

});

};

在我的global.asax中

Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)

HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*")

If (HttpContext.Current.Request.HttpMethod = "OPTIONS") Then

HttpContext.Current.Response.AddHeader("Cache-Control", "no-cache")

HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE")

HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept")

HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000")

HttpContext.Current.Response.End()

End If

End Sub

在我的Web.config中

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值