views:

32

answers:

2

I have a .NET 3.5 website that is uploading files to a SQL Server 2008 filestream. This all works great until I hit a certain file size and I unexpectedly get odd error returns in the browser.

In IE 7, if I upload a file with a size of about 100 meg, the browser returns after about 2 minutes with an error saying "Internet Explorer cannot display the webpage". Completely generic and totally useless error. Were it a timeout issue, then I would expect to see an error with a little more explanation.

In Firefox 3.6.7, when uploading the same file the browser returns after about 4 minutes with an equally generic and useless error that says "The connection was reset". Again, were it a timeout error (eg - somewhere in my code I have a connection timing out) then I would at the very least expect Firefox to return after 2 minutes with the generic error, because IE returned after just 2 minutes.

I need some ideas on how to diagnose this and hopefully track down what is causing the problem.

Also, I have the file upload size limited to 1 gig in the web.config.

<!-- 1 Gig upload -->
<httpRuntime maxRequestLength="1048576" />

EDIT:

Are there any settings in IIS 7 that could be affecting this? I'm not an IIS guru, so I may have configured my website wrong.

A: 

Jagd,

Try modifying your webconfig with:

<system.web>
  <httpRuntime executionTimeout="999999" maxRequestLength="51200" />
Jason Slocomb
Thank you. I'm not familiar with these two attributes, so I'll look into them and get back to you!
Jagd
Er... I take that back, I'm familiar with the latter one, as I said in my original post.
Jagd
Well, I set the maxRequestLength = 3600, which is one hour, but it keeps coming back with a 404 after not even a minute now. It does this in both IE and Firefox.
Jagd
Did you try it with a small file first to rule out anything syntactical?
Jason Slocomb
The magical number lies somewhere in between 29174 KB and 29308 KB. I've got tons of PDF's that I can experiment with, and through a bunch of uploads I found that the one PDF at 29174 KB will upload, but the next highest in size that I have (the 29308 KB one) gets the 404. I'm not convinced that it's a timeout either, because the 404 seems to be thrown within 15 seconds of uploading when it does occur.
Jagd
@Jason - yes, I have.
Jagd
Any errors in the event log?
Jason Slocomb
@Jason - No, but a log file in IIS is what eventually led me to the answer, which I'm about to post.
Jagd
A: 

The answer:

MSDN requestLimits

The web.config has a section for fine tuning websites running under IIS 7. I'm amazingly ignorant when it comes to IIS 7, so it's small wonder that I ran into this problem.

<security>
  <requestFiltering>
    <!-- 2 gig max upload --> 
    <requestLimits maxAllowedContentLength="2147483648"></requestLimits>
  </requestFiltering>
</security>

The default value for maxAllowedContentLength is 30000000 bytes. Do a bit of math and you'll discover that 30000000 bytes equals 29,296.875 KB, which explains why I could upload a file with 29,174 KB, but not one with 29,308 KB.

As soon as I upped this valued, my file upload worked for the bigger PDF's.

Jagd
Congrats Jagd, I learned something here as well.
Jason Slocomb