Ajax call exceeding acceptable URI length

I have a ASP.NET MVC configuration, and I am building a reportgenerator. I am outputting a JQuery table, so that the user may sort and rearrange it, before fetching it as a PDF. My PDF component is .NET-based, and so I need to send the modified table back to the server via AJAX.The problem is that the …

via Asp.Net Developed Tutorials » Search Results » ajax:

Ajax call exceeding acceptable URI length

I have a ASP.NET MVC configuration, and I am building a reportgenerator. I am outputting a JQuery table, so that the user may sort and rearrange it, before fetching it as a PDF. My PDF component is .NET-based, and so I need to send the modified table back to the server via AJAX.
The problem is that the URI can get as large as 100k characters, making the server respond with a status of 414 (Request-URI Too Long). It seems that IIS does not allow URIs greater than some few thousand characters.
I admit that it seems strange to compose a URL that big, so I think I might be missing something. Is there another way to post the data to the server, or maybe possible to solve this in another way?
……………………………………….

The recommended way of sending data longer than a few hundred characters is to use HTTP POST instead of GET. GET appends all data to the URI as key-value pairs (e.g. ?foo=bar&baz=blah), whereas POST puts the data into the request body. There is a limitation to the total request length as well, but it’s far larger than the limit imposed on URIs. On the jQuery side, switching from GET to POST is trivial – read the documentation on jQuery.ajax() for details. On the server side, you may have to change things so that the parameters are read from POST instead of GET, but in most cases, this is relatively easy as well.
……………………………………….

The key in your question is post. You need to POST back to the server.
API jQuery AJAX post method.
$.post(url, [data], [success(data, textStatus, XMLHttpRequest)], [dataType]);

For more info: Ajax call exceeding acceptable URI length

Asp.Net Developed Tutorials » Search Results » ajax

Ajax call exceeding acceptable URI length

Share this post:

Related Posts

Leave a Comment