httpRuntime - Increase file size limit from 4 MB to bigger size in ASP.NET

Tuesday, April 21, 2009 |

I wrote an article on how to upload image to SQL Server database BLOB fileld and retrieve it back. You can refer that article at:

After trying to implement this functionality, one of my readers has observed that he can’t upload the file big file. He came to me for solution. Actually in ASP.NET you can upload file with maximum size of 4MB. That is the default settings. Than how could you upload bigger file than 4096 kb? Isn’t there any way around? Because this is somehow very common need.

Well, they is a will, there is way!!! You can set maximum file size with httpRuntime tag. You can set this at machine.config or web.config but I insist, not to touch machine.config file as it has web server wide effect, you should set it in web.config so that it affect one website or one subdirectory in which web.config reside.

You have to add one line under <system.web> element of your web.config. The line is

<httpRuntime maxRequestLength="20480" />

This will increase file limit from 4 MB to 20MB.


Reference: Ritesh Shah
Note: Microsoft Books online is a default reference of all articles but examples and explanations prepared by Ritesh Shah, founder of