I have an ASP.Net MVC application that allows users to upload images. When I try to upload a really large file (400MB) I get an error.
I assumed that my image processing code (home brew) was very inefficient, so I decided I would try using a third party library to handle the image processing parts.
Because I'm using TDD, I wanted to first write a test that fails. But when I test the controller action with the same large file it is able to do all the image processing without any trouble.
The error I get is "Out of memory".
I'm sure my code is probably using a lot more memory than it needs to but I just want to know why my test passes.
The other difference is that I'm using SWFUpload which is not used with the test. Could this be the cause?
There is really no hard-limit for upload sizes. However, if you're on a 32-bit process, you may be limited by the amount of memory your asp.net worker process can address. Once it gets around 800mb, it becomes very unstable.
The timeout settings mentioned by Bravax are also a good place to check.
Cheers on using TDD!
You need to be sure to pipe data off the input stream into a filestream of some form so that the whole request entity isn't needed in memory.
From MSDN:
There can be memory limits configured in either the web.config or machine.config, or both.
In web.config the section is:
In machine.config the section can also be the httpRunTime section, similar to:
The aspnet process can also be limited to a percentage of the total memory using the processModel section, see:
http://msdn.microsoft.com/en-us/library/7w2sway1.aspx
I've encountered similiar problems to the one you described cause by those settings.
In particular the ProcessModel memorylimit attribute.
Where exactly does the exception originate from?
AFAIK there's no 400MB-caliber limit to image sizes in ASP.net/.Net. I'm writing a project where some files are much larger. There might be some higher limit I'm not aware of, of course, but it would seem odd and arbitrary.
Are you running on a 64 bit machine? Could your image file - uncompressed (is it 400MB in jpg?) - test the the 2GB limit of your process's address space?