Mujassir Nasir
Mujassir Nasir

Reputation: 1720

Getting 404 error for JSONP Get request when deployed on IIS

I am using jquery AJAX with datatype jsonp. It is working fine on my local dev environment with huge amount of data. But when I deployed it on IIS it only works fine with a request of length less than 2121 characters, it gives 404 error for more than 2121 characters.

I have also searched about too long url error, for too long url it should give 414 error code.

I have also used following in my web.config but nothing improved

<httpRuntime maxRequestLength="8192" executionTimeout="180" />

Let me know where I am wrong.

Upvotes: 1

Views: 114

Answers (2)

Mujassir Nasir
Mujassir Nasir

Reputation: 1720

After a long research I got it fixed, it was not about Asp.Net configuration it was about IIS configuration following is the solution

IIS

-> Click on my site under 'Sites' in the left Connection pane

-> Double click on Request Filtering (under IIS in main content pane)

-> Under 'Actions' in the right hand window pane click 'Edit Feature Settings'

-> Increase 'Maximum URL length' and 'Maximum query string' in the resulting pop up

Upvotes: 1

Kashif Hanif
Kashif Hanif

Reputation: 1726

I had to supply both of these values in the web.config to work it fine.
If you are using IIS for hosting your application, then the default content size is 4MB. To increase it, please use this below section in your web.config - as you

 <system.web>
        <httpRuntime maxRequestLength="1048576" />
    </system.web>

And in system.webServer, you need to add this part for IIS 7 and above

<security>
    <requestFiltering>
        <requestLimits maxAllowedContentLength="1073741824" />
    </requestFiltering>
</security>

maxRequestLength has 1048576 KILOBYTES, and maxAllowedContentLength has 1073741824 BYTES. Make sure that you're adding this setting to the main Web.config instead of the one inside the Views folder if you want to handle this globally.

Upvotes: 1

Related Questions