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

  • SEARCH
  • Home
  • 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 4271752
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:29:05+00:00 2026-05-21T07:29:05+00:00

Suppose someone: visits and ASPX page (http get request). sets a too large file

  • 0

Suppose someone:

  1. visits and ASPX page (http get request).
  2. sets a “too large” file in a file uploader and clicks the upload button (http post request).

I don’t care to have a custom error page served; that’s dumb, and disrupts the application.

I want to HANDLE the error programmatically. It can be intercepted (after the entire request has been received, I think) by the Application_BeginRequest handler of global.asax, as posted here.

What I’d like to do is remove the oversized file from the request, set some kind of flag in something like “HttpContext.Current.Items[“filetoolarge”] = true”, then do a Server.Transfer to the same page, so that the request runs as though the file was never sent, except now there’s this error flag that the page would of course check and display a nice error message when found.

Can this be done?

  • 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-21T07:29:05+00:00Added an answer on May 21, 2026 at 7:29 am

    I posted the solution here: Where do I catch and handle maxAllowedContentLength exceeded in IIS7?

    My solution involves overriding the page’s OnError handler, and I think it works only in .NET 4.0, because it involves getting the last exception as an HttpException and checking the WebEventCode property, which seems to be new in the .NET 4.0 framework.

    There is another solution there that involves intercepting the Application_EndRequest global application handler, where both the StatusCode and SubStatusCode property values are available, but I don’t think it works, because the response has probably already been flushed to the client by the time the EndRequest event is raised.

    From my experience, both the OnError and Application_EndRequest methods run almost immediately, long before the server could have possibly received the entire request, so it probably gets fired as a result of some early warning about the request size.

    I have tested the OnError method, and it works flawlessly, aside from the unavoidable delay where the browser insists on finishing the upload of its request before handling and displaying the server’s response.

    Information on Web Event Codes can be found here – http://msdn.microsoft.com/en-us/library/ff650306.aspx

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

Sidebar

Related Questions

Suppose I sent a large jar or war file to someone. Could I later
Suppose someone hits in url http://mysite.com/comments/view/13 But that absentaction is not present in comments
Suppose someone wrote a method that opens a certain file and forgets to close
Let me explain. Suppose I want to teach Python to someone who only speaks
suppose someone enter this search (on an form): Nicole Kidman films Which SQL i
Suppose I have a URL in my query string. Someone told me that Google
Can someone explain the solution of this problem to me? Suppose that you are
suppose we have an internet web site with high visits, say, 10M pv per
Suppose someone (other than me) writes the following code and compiles it into an
Suppose I read code written by someone else where from import * is used,

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.