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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:54:01+00:00 2026-05-23T07:54:01+00:00

I built an http module in C# that just overrides the EndRequest of a

  • 0

I built an http module in C# that just overrides the EndRequest of a lifecycle, checks the status code of the response header and modifies the response code it if needs be. Something like:

HttpContext context = ((HttpApplication)source).Context;
if (context.Response.StatusCode == 200)
{
    context.Response.StatusCode = 404;
}

This seems to work fine for me when I test it against localhost (real IIS), but when I enable intranet access and test from another computer it fails every time.

The error I am seeing when I test via another computer is:

“Server cannot set status after HTTP headers have been sent.”

I also noticed that requests the same file twice, whereas locally it only requests the file once. I heard someone say something about output buffering, but I also tried setting the on BeginRequest response OutputBuffer to true and got the same results.

Thoughts?

  • 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-23T07:54:02+00:00Added an answer on May 23, 2026 at 7:54 am

    You need to modify the response before the headers are sent. I’ve never had to do this, but I would guess the correct event would be PreSendRequestHeaders. link

    Here’s an example of setting headers in this event.

    If this event doesn’t work for you, check out some events after the handler’s post process in the pipeline: http://blogs.msdn.com/b/carloc/archive/2007/12/19/application-page-and-control-lifecycle.aspx Be careful, though, because you may have to rewrite your code for the IIS 7 integrated pipeline.

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

Sidebar

Related Questions

I have built an http module that detect file openings. I don't want any
I've built an http module to log file downloads on a server. When a
I have an external JAR signpost-core-1.2.1.1.jar (from http://code.google.com/p/oauth-signpost/ ), that I want to include
I built up this regex at http://regextester.com to parse YSOD but VS is complaining
I have built a simple menu in jQuery http://vanquish.websitewelcome.com/~toberua/ Here is a sample of
I have built a website and when my users load up http://info.salemgolfclub.org/Account/Logon the username
I built some cross fade rollovers in IE7 using this single image technique: http://jqueryfordesigners.com/image-cross-fade-transition/
Just compiled 5.3.3 from source (win32). Trying to test some header() stuff but it
I am trying to build a webservice that manipulates http requests POST and GET.
I am using an http proxy and the Mechanize module. I initialize the mechanize

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.