Click here to Skip to main content
Click here to Skip to main content

Setting up Web.config to allow uploading of large files by ASP .NET applications

, 29 Jun 2005 Apache
Rate this:
Please Sign up or sign in to vote.
This article shows how to setup Web.config to allow uploading of files larger than 4 MB by ASP.NET applications.


During the construction of an intranet application that allows users to upload documents and share information between users, I noticed that when a user tries to upload files that are larger than 4 MB, he is asked for the user/password and even if he enters the correct user/password, the file is not uploaded, and he gets a HTTP 401.1 error.

Of course, this should not be an article, but CodeProject doesn't have a "quick tip section"-like, so here it goes.

The problem

By default, Machine.config is configured to accept HTTP Requests upto 4096 KB (4 MB) and it is reflected in all your ASP.NET applications. You can change the Machine.config file directly, or you can change only the Web.config file of the application(s) you want to.

The solution

Open your Web.config file, and just below the <system.web> tag, add the following tag:


Now, just take a look at the maxRequestLength="4096" attribute of the <httpRuntime> tag. As you may have realized, all you need to do is change the value to some other value of your choice (8192 for 8 Mb, 16384 for 16 Mb, 65536 for 64 Mb, and so on...).

That's it. I hope it is useful to you.


This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


About the Author

Caio Proiete
Team Leader Nephila Capital
Bermuda Bermuda
Caio Proiete has been programming for over 10 years, having first started with Clipper Summer'87.
He loves software development and reverse engineering. Today his main development technologies includes ASP .NET MVC, jQuery, HTML5, Silverlight, and WCF. He also has the following titles:
MVP - Microsoft Most Valuable Professional;
MCT - Microsoft Certified Trainer;
MCPD - Microsoft Certified Professional Developer;
MCTS - Microsoft Certified Technology Specialist;
MCSD - Microsoft Certified Solution Developer;
MCDBA - Microsoft Certified Database Administrator.
Technical blog:
Follow on   Twitter   LinkedIn

Comments and Discussions

BugError 500 when you publish my web.config PinmemberPeterConchaR23-May-14 6:59 
GeneralRe: Error 500 when you publish my web.config PinmemberCaio Proiete23-May-14 15:42 
QuestionVery helpful PinmemberAndrew Fenster30-Aug-13 9:25 
AnswerRe: Very helpful PinmemberCaio Proiete23-May-14 15:42 
QuestionWhat happens to the maximum time allowed for timeouts Pinmemberthabomoj27-Mar-13 3:00 
GeneralMy vote of 5 PinmemberNikhil_S8-Jan-13 2:59 
GeneralRe: My vote of 5 PinmemberCaio Proiete23-May-14 15:43 
GeneralMy vote of 5 PinmemberSweetynewb1-Aug-12 2:14 
GeneralRe: My vote of 5 PinmemberCaio Proiete23-May-14 15:43 
GeneralMy vote of 5 PinmemberAngelinena16-Mar-12 6:33 
GeneralRe: My vote of 5 PinmemberCaio Proiete23-May-14 15:43 
GeneralMy vote of 5 PinmemberAmit Kumar Tiwari28-Dec-10 17:49 
GeneralRe: My vote of 5 PinmemberCaio Proiete23-May-14 15:43 
Generallogin.aspx PinmemberAjay Kale New27-Sep-10 1:13 
GeneralUseful Pinmembermbaocha6-May-09 17:53 
GeneralUploading files greater then 5 mB and timeout issue Pinmemberdigitally_urs24-Jul-05 3:56 
GeneralCommon Problem Pinmemberoykica30-Jun-05 5:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150302.1 | Last Updated 29 Jun 2005
Article Copyright 2005 by Caio Proiete
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid