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

By , 29 Jun 2005
 

Introduction

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:

<httpRuntime 
executionTimeout="90" 
maxRequestLength="4096" 
useFullyQualifiedRedirectUrl="false" 
minFreeThreads="8" 
minLocalRequestFreeThreads="4" 
appRequestQueueLimit="100" 
enableVersionHeader="true"
/>

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Caio Proiete
Software Developer (Senior)
Portugal Portugal
Member
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:
http://caioproiete.net

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionWhat happens to the maximum time allowed for timeoutsmemberthabomoj27 Mar '13 - 2:00 
GeneralMy vote of 5memberNikhil_S8 Jan '13 - 1:59 
GeneralMy vote of 5memberSweetynewb1 Aug '12 - 1:14 
GeneralMy vote of 5memberAngelinena16 Mar '12 - 5:33 
GeneralMy vote of 5memberAmit Kumar Tiwari28 Dec '10 - 16:49 
Generallogin.aspxmemberAjay Kale New27 Sep '10 - 0:13 
GeneralUsefulmembermbaocha6 May '09 - 16:53 
GeneralUploading files greater then 5 mB and timeout issuememberdigitally_urs24 Jul '05 - 2:56 
Hi,
i was to ask that if asp.net is configured to allow uploads of 1 GB of file with a timeout of 30 minutes, and a client application while calling a method aborts say after 2 minutes what will
happen ? will asp.net be able to terminate the call to the method or it'll
wait for the timeout period to kill this particular session? if its going to
wait for timeout how can we handle this situation ?
 

GeneralCommon Problemmemberoykica30 Jun '05 - 4:57 

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

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