views:

455

answers:

3

When working with HTTP modules, has anyone noticed that the final two events in the pipeline -- PreSendRequestHeaders and PreSendRequestContent -- don't always run?

I've verified that code bound to EndRequest will run, but will not when bound to either PreSendRequestHeaders or PreSendRequestContent.

Is there a reason why? I thought perhaps it was a caching issue (with a 304 Not Modified, you don't actually send content...), but I've cleared caches and determined that the server is returning 200 OK, which would indicate that it sent content.

This is a problem because the StatusCode of the response defaults to 200 and my understanding is that it doesn't get updated to something like a 404 or 206 until those two final methods. If I check the StatusCode during EndRequest, it will always read 200.

A: 

I'm injecting a cookie header on the PreSendRequestHeaders event and have yet to run into an issue of it not firing...

Chuck Conway
A: 

Maybe it has to do with HttpResponse.BufferOutput. If buffering is turned off, it seems like all of the headers and some of the content would have already been sent by the time these events fire.

William Gross