Apr 06, 2006 06:47 PM|Telanas|LINK
How do I add custom headers to a request (ASP.Net 2.0)?
I have a need to add custom headers to a request before it is processed. I first created an HttpModule but quickly found that the context.Request.Headers collection is read-only.
After many failed ideas I attempted creating a custom DefaultHttpHandler. This custom DefaultHttpHandler overrides BeginProcessRequest().
I assumed that I would be able to write some code to add the custom headers into the request (or a copy of the request, or somewhere else in the context) before making a call to base.BeginProcessRequest() using my modified context object.
This seems to work some of the time when I add my headers to the base.ExecuteUrlHeaders collection.
But I’m not sure that I should be adding headers into an object that is not directly derived from the context. Also the base.ExecuteUrlHeaders is not always instantiated when my custom DefaultHttpHandler is called, it can be null, and
quite often is.
Is there a proper way to add headers to a request object using an HttpModule or HttpHandler?
David Wang (awesome guy) alludes to the fact that it can be done in many posts, but I’m having a problem getting the subtitle points worked out. I’m using IIS6 with ASP.NET 2.0
Oh yea, I wrote an ISAPI filter that does the job just fine, why is it so hard to get the same thing working in .Net?
Thanks in advance!