<p>I want to implement an ISAPI filter like feature using HttpModule in IIS7 running under IIS Integrated Request Processing Pipeline mode.</p>

<p>The goal is to look at the incoming request at the Web Server level, and inject some custom HttpHeaders into the request. <code>(for ex: HTTP\_EAUTH\_ID)</code></p>

<p>And later in the page lifecycle of an ASPX page, i should be able to use that variable as</p>

<pre><code>string eauthId = Request.ServerVariables["HTTP\_EAUTH\_ID"].ToString();
</code></pre>

<p>So implementing this module at the Web Server level, is it possible to alter the ServerVariables collection ?? </p>

[{'answer_id': 60696, 'author': 'Joel Martinez', 'author_id': 5416, 'author_profile': 'https://Stackoverflow.com/users/5416', 'pm_score': 0, 'selected': False, 'text': '<p>I believe the server variables list only contains the headers sent from the browser to the server.</p>\n'}, {'answer_id': 60728, 'author': 'Gulzar Nazim', 'author_id': 4337, 'author_profile': 'https://Stackoverflow.com/users/4337', 'pm_score': 3, 'selected': True, 'text': '<p><a href="http://msdn.microsoft.com/en-us/library/system.web.httprequest.servervariables.aspx" rel="nofollow noreferrer">HttpRequest.ServerVariables</a> Property is a read-only collection. So, you cannot directly modify that. I would suggest storing your custom data in <a href="http://www.odetocode.com/Articles/111.aspx" rel="nofollow noreferrer">httpcontext</a> (or global application object or your database) from your httpmodule and then reading that shared value in the aspx page.</p>\n\n<p>If you still want to modify server variables, there is a hack technique mentioned in this <a href="http://forums.asp.net/t/1125149.aspx" rel="nofollow noreferrer">thread</a> using Reflection.</p>\n'}, {'answer_id': 61224, 'author': 'Tyler', 'author_id': 5642, 'author_profile': 'https://Stackoverflow.com/users/5642', 'pm_score': 0, 'selected': False, 'text': "<p>You won't be able to modify either the <code>HttpRequest.Headers</code> or the <code>HttpRequest.ServerVariables</code> collection. You will however be able to tack on your information to any of:  </p>\n\n<pre><code>HttpContext.Current.Items\nHttpContext.Current.Response.Headers\n</code></pre>\n\n<p>Unfortunately, <code>Request.Params, Request.QueryString, Request.Cookies, Request.Form</code> (and almost any other place you'd think of stuffing it is read only.</p>\n\n<p><strong>I'd strongly advise against using reflection if this is a HttpModule you're planning on installing into IIS 7</strong>. Given that this code will be called for (potentially) every request that goes through the web server it'll need to be really fast and reflection just isn't going to cut it (unless you have very few users).</p>\n\n<p>Good luck!</p>\n"}]
['https://Stackoverflow.com/questions/60672', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1647/']