0

Well, jqgrid in my form work normally when my parameter in get method is short.
But when my parameter is so long

  • about 4850 character
  • it returns error 404 not found and my webmethod not fire.
  • as I know there is no limitation on query string legnth.
  • Is there any limitaion on query string?
  • Is there any solution for this problem?

thanks and sorry for my bad english
EDIT
this is my code:

jQuery("#jqGridReport").jqGrid({
ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
direction: 'rtl',
url: 'Handler/BrnTotal.ashx',
datatype: "local",
colNames: ['blah','blah','blah'],
colModel: ['blah','blah','blah',],
        rowNum: 50,
        mtype: 'POST',
        loadonce: true,
        pager: '#jqGridReportPager',
        sortname: 'BRName',
        viewrecords: false,
        pgtext: null,
        sortorder: 'desc',
        caption: "شعب",
        hidegrid: false,
        scrollOffset: 0,
        autowidth: true,
        altRows: true,
        altclass: 'myAltRowClass'
    });
    jQuery("#jqGridReport").jqGrid('navGrid', '#jqGridReportPager', { edit: false, add: false, del: false });
    jQuery("#jqGridReport").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false, defaultSearch: "cn" });


the grid is empty at first.when user select parameter and submit button,this method will run

branchlist = idsel.join(",");
        selectedBrnWork = $('#hiddenField').val();
        startDate = $("#txtStartDate").val();
        endDate = $("#txtEndDate").val();
        $("#jqGridReport").jqGrid('setGridHeight', 'auto');
        var newurl = 'Handler/BrnTotal.ashx?startDate=' + startDate + "&endDate=" + endDate + "&brlist=" + branchlist + "&selectedBrnWork=" + selectedBrnWork;
        $("#jqGridReport").jqGrid('setGridParam', { url: newurl });
        $("#jqGridReport").jqGrid('setGridParam', { datatype: 'json' }).trigger('reloadGrid');
        $("#element_to_pop_up").bPopup().close();


This is request header when it works:

POST /Handler/BrnTotal.ashx?startDate=1394/05/26&endDate=1394/05/26&brlist=32,50,61&selectedBrnWork=1 HTTP/1.1

and this is when it doesnt work:

POST /Handler/BrnTotal.ashx?startDate=1394/05/26&endDate=1394/05/26&brlist=32,50,61,73,84,92,103,148,149,160...,...,...,2113,2114,2115,2116,2117,2118,2119,2120,2121,2122,2123,2124,2125,2124,2175,2176,2177,2178,2179,2180,2181,2182,2183&selectedBrnWork=1 HTTP/1.1


I short brlist because it is so long

siavash
  • 17
  • 6

1 Answers1

1

The problem seems to me independent from jqGrid. If you need to send many (or long) parameters to WebMethod the you should use HTTP POST instead of HTTP GET, because the parameters of GET request will be appended to the URL. There are limitations of URL size. The exact maximal length of URL depends on the web browser which you use. Safe limit is about 2000 characters (see the answer for example).

Thus I would recommend you to use mtype: "POST" instead of default mtype: "GET" used by jqGrid if no mtype is specified.

UPDATED: You send parameters in the wrong way. The posted code just add parameters startDate, endDate, brlist explicitly to URL. It's wrong. The data should be send in the body of the POST request. You should use postData parameter of jqGrid for it. I would recommend you to use postData in function form:

url: 'Handler/BrnTotal.ashx',
datatype: "json",
mtype: 'POST',
postData: {
    startDate: function () { return $("#txtStartDate").val(); },
    endDate: function () { return $("#txtEndDate").val(); },
    brlist: function () {
        var idsel = jQuery("#jqGridReport").jqGrid("getGridParam", "selarrrow");
        return idsel.join(",");
    },
    selectedBrnWork: function () { return $('#hiddenField').val(); }
}
Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • thanks for response,I changed mtype to "POST" but it still not working.Should I change anything else? – siavash Aug 17 '15 at 07:06
  • @siavash: First of all you should append your question with the code which you use. It's difficult to help you just guessing what you do. Moreover I recommend you to use [Fiddler](http://www.telerik.com/fiddler) or Developer Tools of IE or Chrome (press F12 to start) to make HTTP trace (monitor Network traffic). If you will see what exactly will be send to the server and returned back you can localize the error much quickly. – Oleg Aug 17 '15 at 07:09
  • I edit my question and add my code,Whould you please check it – siavash Aug 17 '15 at 08:27
  • @siavash: You should use `postData` to extend parameters which will be send to the server in **the body** request. If you would use `mtype: 'GET'` then the parameters will be appended to the URL, but it will be placed correctly in the body if you use `mtype: 'GET'`. See **UPDATED** part of my answer. – Oleg Aug 17 '15 at 09:01
  • @siavash: The `colModel` which you use in your code seems to be wrong: `colModel: ['blah','blah','blah',]`. I hope it's just dummy and you use correct values. I fixed additionally `selectedBrnWork` in `postData`. I hope that you found the problem already. – Oleg Aug 17 '15 at 09:35