Search code examples
asp.netuploadifywindows-authentication

Handle maximum file upload size in asp.net webforms application


I have a webforms application configured with maxRequestLength="4096". This is fine, I don't mind preventing requests of this size. Now, I have a FileUpload control that the user could potentially use to cause a request that is too large. How do I gracefully handle the maximum request length exceptions?

I have tried using the Uploadify plug in to prevent files that are too large, which works fine in my development machine.

The problem is we use Windows Authentication on the production site, and I am reading that Flash can have issues handling Windows Authentication. It seems intermittent, my client sees a 401 error with Uploadify on Chrome, and I can replicate it with Firefox.

Should I be handling this differently? All I want to do is gracefully handle maxRequestLength exceptions, but I've ended up down this rabbit hole trying to make Uploadify work when it brings with it a lot of other functionality that I don't actually want (multiple files / file queue / async post).

Thanks!


Solution

  • There is no way to gracefully handle exceeding IIS's "maxRequestLength" setting.

    The only way around this is to set maxRequestLength to some a very high number of kBytes, and then check the ContentLength after the file has been uploaded.

    You can't display a custom error page since there is no corresponding HTTP code.