I am working on ASP.NET MVC 2 application. the website runs under SiteMinder (3rd party agent) for authentication. The Siteminder injects custom header to the incoming HTTP request. But when I try to read the custom header, I donot get the value.
System.Web.HttpContext.Current.Request.ServerVariables["CustomKey"];
Looks like these custom headers are getting stripped by MVC. I hav eensured that the headers are for sure getting injected by SiteMinder.
Am I doing anything wrong while reading as shown above?
To view the request or response HTTP headers in Google Chrome, take the following steps : In Chrome, visit a URL, right click , select Inspect to open the developer tools. Select Network tab. Reload the page, select any HTTP request on the left panel, and the HTTP headers will be displayed on the right panel.
Custom HTTP headers can be used to filter requests or specify a value for the Accept header.
In the Home pane, double-click HTTP Response Headers. In the HTTP Response Headers pane, click Add... in the Actions pane. In the Add Custom HTTP Response Header dialog box, set the name and value for your custom header, and then click OK.
You're looking for HttpRequest.Headers
, not ServerVariables
which represent variables served by IIS to the application:
System.Web.HttpContext.Current.Request.Headers["CustomKey"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With