更新时间:2023-12-05 16:19:28
可能在另一台机器上部署了应用程序的虚拟目录,并让你在使用的绝对URL没能找到。
尝试使用这个code,而不是
VAR urlStr ='<%:Url.Content(〜/项目/ ItemCount中)%>';
I'm posting to an ActionMethod to retrieve some customer counts. The post works fine from my local machine. When deployed to another server its throwing 404 errors. My post is below. I'm not sure why this has stopped working.
var urlStr = "/Items/ItemCount/";
jQuery.ajax({
type: 'POST',
dataType: 'json',
url: urlStr,
async: false, //wait on the result to be returned...
success: function (DocData) {
window.currentCount = DocData[0];
window.maximumAllowed = DocData[1];
},
cache: false,
error: function (request, status, error) {
alert(request.responseText);
}
});
<HttpPost()> _
Function ItemCount() As JsonResult
Dim Items As List(Of MyItems) = GetItems()
Dim Total As Integer = Items .Count
Dim Max = 5
Dim Data As New ArrayList
Data.Add(TotalDocs)
Data.Add(MaxDocs)
Return Json(Data)
End Function
Probably on the other machine you have deployed the application in a virtual directory and so the absolute url you're using could not get found.
Try to use this code instead
var urlStr = '<%: Url.Content( "~/Items/ItemCount" ) %>';