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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:36:24+00:00 2026-05-13T14:36:24+00:00

protected void Application_BeginRequest(object sender, EventArgs e) { const int maxFileSizeKBytes = 10240; //10 MB

  • 0
protected void Application_BeginRequest(object sender, EventArgs e)
    {


        const int maxFileSizeKBytes = 10240; //10 MB
        const int maxRequestSizeKBytes = 305200; //~298 MB

        if (Request.ContentLength > (maxRequestSizeKBytes * 1024))
        {
            Response.Redirect(".aspx?requestSize=" + Request.ContentLength.ToString());
        }


        for (int i = 0; i < Request.Files.Count; i++)
        {
            if (Request.Files[i].ContentLength > (maxFileSizeKBytes * 1024))
            {
                Response.Redirect(".aspx?fileSize=" + Request.Files[i].ContentLength.ToString());
            }
        }

    }

This code is in Global.asax.cs page.
I need to redirect to the page that triggered this check. And I need to know the ticketId or projectId parameter. For example I create new ticket at the View Project page /Project/ViewProject.aspx?projectId=1 I need to redirect to this page with a meaningful message to the user, because I think that redirecting to another page to display the error message is not a good idea.

  • 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-13T14:36:24+00:00Added an answer on May 13, 2026 at 2:36 pm

    Why don’t you put these checks in the Load handler of a base Page class that ViewProject (and anything else needing the checks) derives from? Then you can just make an error Label visible if the check fails. Untested code:

    public class BasePage : Page{
      protected virtual Label ErrorLabel { get; set; };
      protected override OnLoad(object sender, EventArgs e) {
        base.OnLoad(sender, e);
    
        const int maxFileSizeKBytes = 10240; //10 MB
        const int maxRequestSizeKBytes = 305200; //~298 MB
    
        if (Request.ContentLength > (maxRequestSizeKBytes * 1024))
        {
            ErrorLabel.Text = "Request length "+Request.ContentLength+" was too long."
            ErrorLabel.Visible = true;
        }
    
    
        for (int i = 0; i < Request.Files.Count; i++)
        {
            if (Request.Files[i].ContentLength > (maxFileSizeKBytes * 1024))
            {
                ErrorLabel.Text = "File length "+ Request.Files[i].ContentLength +" was too long."
                ErrorLabel.Visible = true;
            }
        }
      }
    }
    
    public class ViewProject : BasePage {
      protected override Label ErrorLabel {
        get { return LocalErrorLabel; } // something defined in HTML template
        set { throw new NotSupportedException(); }
      }
    }
    

    This way you stay on the same page and you already have ticketId and projectId.

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

Sidebar

Ask A Question

Stats

  • Questions 306k
  • Answers 306k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have you tried http://iphonedevwiki.net/index.php/Xcode#Developing_without_Provisioning_Profile? The link you've provided only works… May 13, 2026 at 9:11 pm
  • Editorial Team
    Editorial Team added an answer You could do <input type="image" src="url-where-your-image-lives" onclick="Element.up(this, 'form').submit()"> This assumes… May 13, 2026 at 9:11 pm
  • Editorial Team
    Editorial Team added an answer while (GetWhitespace(textStream)) ; May 13, 2026 at 9:11 pm

Related Questions

I have a class Application that my global.asax inherits from. The class has this
Is there any way i can access the page object from within the global.asax
I'm currently developing an ASP.NET application which uses a MasterPage and I want to
I'm wondering how the concurrency in a web application actually works. Ive read several
I am just beginning to localize an ASP.NET MVC application. Most of the strings

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.