POST Ajax call results in not found using jqGrid and ASP.NET MVC 2 on IIS6

戏子无情 提交于 2019-11-29 16:20:20
Oleg

Look at Deploy asp.net mvc beta to iis 6 causing 404's and http://blog.stevensanderson.com/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/.

Do you have more URL in your application where POST are used? Are they work? Do you have more URLs without an extension like .aspx or .mvc? Are they work?

UPDATED: I had a problem with different base/root parts of my URL in all JavaScripts like you. Because you use jqGrid, I think you have the same problem. If I publish my solution in a virtual directory on a Web Server, then all URLs which call my JavaScripts will be changed. So I give window.location.pathname and split it with '/', then I find out a new rootPath corresponds to the new location. Such rebasing of URLs I placed in a function which I call inside of all JavaScripts of my solution. Hire is code fragment which works perfect on with my site:

var pathArray = window.location.pathname.split( '/' );
var rootPath = '';
for (var i = 0; i < pathArray.length; i++) {
    var p = pathArray[i];
    if (p === "") {
        continue;
    }

    if (p.toLowerCase() !== 'home') {
        rootPath += '/';
        rootPath += p;
    } else {
        break;
    }
}
this.urlBase = rootPath + '/Repository.svc';
this.urlExportBase = rootPath + '/ExportToExcel';

The solution is not perfect, but it works. It can be that you should change this "rebasing" function to make it working with your side.

Use the mvc helpers to generate the url for the jqGrid ajax function to ensure the correct url is used.

$('#mygrid').jqGrid({ 
    url: '<%= Url.Action("MyControllerJsonAction", Model.RouteValues) %>' 
});

When I use VS2012 release my project(MVC+Kendo UI) to IIS6.0 .The problem come out. F12 debug the error is 404,Chrome say the page can't find .

It's because the url is not right when you should add the Doamin in the url:

The right code is:

function QueryExpSendList() {
var EValid = true;
var uri = AJAXBaseUrl;
if (AJAXBaseUrl.indexOf("localhost") > 0) {
    uri = AJAXBaseUrl + "AJAX/QuerySendList/";
}
else {
    uri = AJAXBaseUrl + "KQExpress/AJAX/QuerySendList/";
}
GenerateExpressSendGrid(uri);
$("#QueryResult").show();

}

The Error Code:

function QueryExpSendList() {
var EValid = true;
var uri = AJAXBaseUrl + "AJAX/QuerySendList/";
GenerateExpressSendGrid(uri);
$("#QueryResult").show();

}

By sirili@163.com

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!