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 9203029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:23:18+00:00 2026-06-17T23:23:18+00:00

I am trying to solve a problem. I want to upload a file with

  • 0

I am trying to solve a problem. I want to upload a file with the fileupload control with a max length of 10mb ( for example ). I maked all controls on the dimension of the file, but when i try to upload a file greater than 10mb the browser show me the “page fault” page.

There is a way to intercept the error by server side ?

thank you all

protected void Page_Load(object sender, EventArgs e)
{
    if (IsPostBack)
        StatusLabel.Text = Server.MapPath("~/prova")
                         + FileUpload1.PostedFile.FileName;

    if (!IsPostBack)
    {
        var config = WebConfigurationManager.OpenWebConfiguration("~");
        var section = config.GetSection("system.web/httpRuntime")
                                     as HttpRuntimeSection;
        section.MaxRequestLength = 10485760*200;
    }

    HyperLink hl = new HyperLink();
}

protected void Button1_Click(object sender, EventArgs e)
{
    if (FileUpload1.HasFile)
    {
        if (Page.IsValid)
        {
            try
            {
                string filename = Path.GetFileName(FileUpload1.FileName);
                FileUpload1.SaveAs(Server.MapPath("~/prova") + filename);
            }
            catch (Exception ex)
            {
                StatusLabel.Text = "Upload status: The file could not be"
                                 + " uploaded. The following error occured: "
                                 + ex.Message;
            }
        }
    }
}

protected void CustomValidator1_ServerValidate(object source,
                                               ServerValidateEventArgs args)
{
    if (FileUpload1.FileContent.Length < 10485760)
    {
        args.IsValid = true;
    }
    else
    {
        args.IsValid = false;
    }
}
  • 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-06-17T23:23:19+00:00Added an answer on June 17, 2026 at 11:23 pm

    You need to change the maxRequestLength.

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <system.web>
        <httpRuntime maxRequestLength="102400" executionTimeout="1200" />
    </system.web>
    </configuration>
    

    If you want to intercept the exception regardless then you’ll need to handle it in Global.asax. Here’s a link to a
    code example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The problem I am trying to solve is that I want to check all
I've been trying to solve this problem all day. I just want to list
I'm trying for hours now to solve this problem.. So.. I want to use
I've been trying to solve this problem all day, and I've read some conflicting
I am trying to solve a minimisation problem and I want to minimise an
I am trying to solve this problem myself but I can't. So I want
I've been trying to solve this problem all day, and haven't found a solution
I'm trying to solve pretty easy problem. I want to establish connection to 2
I'm trying to solve Problem 13 of project euler, which involves the sum of
Trying to solve a problem with templatetags. I have two templatetags: @register.inclusion_tag('directory/_alphabet.html') def alphabet_list(names):

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.