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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:25:17+00:00 2026-05-11T14:25:17+00:00

I searched SO and found this question , but it’s not quite what I’m

  • 0

I searched SO and found this question, but it’s not quite what I’m asking. I’m wondering if a IHttpModule can be created that can inspect the ContentLength of the request, and if so either redirect or somehow throw that request out and create a new one.

Specifically, I’m trying to handle image file uploads, but I’d like to have the request continue on to the upload page with some kind of warning, rather than a flat error page. I have this bit of code that gets hit with a large request:

    private void context_BeginRequest(object sender, EventArgs e)     {         HttpApplication application = (HttpApplication)sender;         HttpContext context = application.Context;          if (context.Request.ContentLength > (4 * 1024 * 1024))         {          }     } 

The execution path enters this IF block like I want it to. But from here, I’m not really sure where to go. Is this a bad approach?

Edit: As it is (without this module), Fiddler is reporting that IIS is returning a 500 code. I’d like to avoid this and have the code return a 200 from the requested page, just with the warning like I said.

  • 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. 2026-05-11T14:25:17+00:00Added an answer on May 11, 2026 at 2:25 pm

    Because of the nature of HTTP, you can’t actually return anything until you read all the request data. When you receive an oversized request, you have two options:

    • Read in all the data and then return a nice error page. This sounds good, but means the user has to wait for the upload to complete before he gets the message that he can’t upload. It also opens a possible DOS attack hole
    • Terminate the request immediately. This gives the user a crappy disconnect page, but preserves security.

    There is a third option — use an advanced component that provides both nice error messages as well as security. You can use flash only components, and there are many of them out there, but of course, if the user doesn’t have flash, you’re out of luck.

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

Sidebar

Related Questions

I've searched around for answers to this question, but not found anything quite on
I have searched for topics specifically to this question but have not found anything
I searched and found this question but did not like the answer. Is there
I searched about this question but can't found any suitable answer: I had been
Sorry if this is a duplicate question...I've searched around and found similar advice but
Searched a lot about this problem but never found a answer, that solved it.
I've searched for an answer and found some c#-examples, but could not get this
I searched the Web about this question but I found nothing: What is the
I have searched this question, and found an answer in MySQL but this is
I searched the web but haven't found a real good answer for this question..

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.