万旬的博客

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 

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?

<httpRuntimemaxRequestLength="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

share|improve this question
 
1  
 
I already have it set way high - maxRequestLength="1048576" – Vaibhav Garg Apr 23 '10 at 4:39
 
Are you uploading a file or posting a page? – Robert Harvey Apr 23 '10 at 4:41
 
I have tried both uploading as a file (using Webclient) as well as posting (HttpWebRequest). the concerned data is a XML document – Vaibhav Garg Apr 23 '10 at 5:13

2 Answers

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)

share|improve this answer
 
posted on 2013-09-10 11:50  蓝波崖  阅读(146)  评论(0编辑  收藏  举报