views:

187

answers:

2

I am testing a HttpHandler that accepts XML. It works fine when a small amount of data is posted but if I post data larger then approx 29mb, I get a asp.net 404 Error.

I am posting to the handler from another handler in the same project and I have tried 2 methods - 1. HttpWebRequest with "POST" 2. WebClient with UploadFile() and UploadData()

I get the same 404 error when the posted data is above 28.6 MB.

I also tried putting a breakpoint right in the beginning of the receiving handler and debugging. It is never hit. Appears like the handler was never called. Works ok for smaller sized data.

I already have the following setting. What am I doing Wrong?

<httpRuntime maxRequestLength="1048576" />

EDIT: I have also tried posting to a different handler that doesnt not consume posted data, just to test, but the results are the same. Environment: Win 7, IIS 7.5, .net 3.5, VS 2008 alt text

+2  A: 

Try to add this section to the web.config file:

<location path="YourHandler.aspx">
    <system.web>
        <httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
    </system.web>
</location>

assuming you handler path is YourHandler.aspx.

Alex
+1  A: 

I discovered that the problem is with IIS 7 and above. It requires the max request length to be set in a different place.

See the following links -

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22943810.html

http://msdn.microsoft.com/en-us/library/ms689462%28VS.90%29.aspx

The default value is 30000000. which is 28.6mb. The correct way to set in web.config is -

  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="1073741824"></requestLimits>
      </requestFiltering>
    </security>
  </system.webServer>

This config cleared the error I was getting. I wish the errors reported were more descriptive, at least on local machines

Does this mean that setting <httpRuntime maxRequestLength="1048576" /> is enough for IIS 6 ? (the live server is win2003)

Vaibhav Garg
Described in more detail http://weblogs.asp.net/jeffwids/archive/2009/09/24/from-iis6-maxrequestlength-to-iis7-maxallowedcontentlengthfile-specifying-maximum-file-upload-size.aspx
Vaibhav Garg