Click here to Skip to main content
12,997,531 members (56,008 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 29 Jul 2011

Restrict the size of file uploads in ASP.NET

, 29 Jul 2011
Rate this:
Please Sign up or sign in to vote.
Specific directories rather than entire application: For individual uploader:int maxSize = 2097151;if (FileUpload1.HasFile &&...

Specific directories rather than entire application:

<location path="Upload">
        <httpRuntime executionTimeout="9999" maxRequestLength="2097151" />

For individual uploader:

int maxSize = 2097151;
if (FileUpload1.HasFile && FileUpload1.PostedFile.ContentLeng­ th <= maxSize)
   //put some logic


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Monjurul Habib
Software Developer (Senior)
Singapore Singapore
A life-long-learner, maker and soft music fan. Likes building things to solve problems. Years of successful records serving mid and large scale .NET applications in domestic and international client environment. Expertise in different areas of software development life cycles and Software Architecture.

Always looks for new technology and loves to get hands dirty Smile | :)

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
Maksud Saifullah Pulak26-Feb-13 20:45
memberMaksud Saifullah Pulak26-Feb-13 20:45 
GeneralRe: My vote of 5 Pin
Monjurul Habib27-Feb-13 8:44
memberMonjurul Habib27-Feb-13 8:44 
GeneralRe: My vote of 5 Pin
Ayesha Atif23-Sep-13 12:41
memberAyesha Atif23-Sep-13 12:41 

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

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

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170622.1 | Last Updated 29 Jul 2011
Article Copyright 2011 by Monjurul Habib
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid