Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7626621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:21:01+00:00 2026-05-31T05:21:01+00:00

I am applying file upload size restriction, that user can’t upload files more than

  • 0

I am applying file upload size restriction, that user can’t upload files more than 30 MB, and give him message if he exceeds the limit.
I am using following code.

if (fileUpload.HasFile)
            {
                if (fileUpload.PostedFile.ContentLength < 30 * 1024 * 1024) // 30 MB
                {
                    if (fileUpload.FileName != null && fileUpload.FileName != "")
                    {
                        UploadFile(fileUpload, "flv,mp3", out videoFileName, out uploadError);
                        if (uploadError != "")
                        {
                            lblMessage.Visible = true;
                            lblMessage.Text = uploadError;
                            return false;
                        }
                    }
                }
                else
                {
                    lblMessage.Visible = true;
                    lblMessage.Text = "File size exceeds the Limits. Please try uploading smaller size file.";
                    return false;
                }
            }

This code works fine in Visual Studio, but when I deploy the application on iis, it doesn’t give me any message if I give more then 30 MB file, and directly upload the file.

where I am doing wrong.

Regards,
Kash

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:21:02+00:00Added an answer on May 31, 2026 at 5:21 am

    Have you used the standard maxRequestLength config property? It may well be that it’s not suitable for your needs but it will work better in not utilising resources one the file limit is reached.

    For an explanantion about how to handle the error see A better way of handling maxRequestLength exceptions

    <system.web>
      <httpRuntime  maxRequestLength="31457280" executionTimeout="360"/>
    </system.web>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a form which allows the user to upload some files to a
I've got an XML data file that I'm applying an XSL stylesheet to, using
I understand that in Flex builder we can right click on a CSS file
I'm applying an XSLT stylesheet to the following XML file: <top xmlns=http://www.foo.com/bar> <elementA />
The problem is to search a password into a big file of size about
I have written an xslt that reads some xml file names and does some
I have a batch file that contains commands to restore a database using patches
I'm building an app that pulls data in from an excel .csv file and
As applying unit-test to some C code, we run into a problem that some
I have patch file describing changes to multiple files to apply to the contents

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.