I'm trying to debug one specific issue with ASP.NET application and I suppose the problem could be somewhere in the server configuration.
Specifically the standard ASP.NET header is sent to the client instead of the header crafted by the ASP.NET application
Date: Fri, 04 开发者_C百科Feb 2011 12:15:04 GMT
Server: Microsoft-IIS/5.1
X-Powered-By: ASP.NET
My question is - where does this header come from exactly? Who is responsible for producing it and sending it to the client? Why would is be sent to the client instead of the once crafted by the application?
That is a Custom HTTP Header and is part of IIS settings for the website;
Custom HTTP headers
You can use this property to send a custom HTTP header from the Web server to the client browser. Custom headers can be used to send instructions from the Web server to the client browser that are not yet supported in the current HTTP specification, such as newer HTTP headers that IIS may not inherently support at the time of the product's release. For example, you can use a custom HTTP header to allow the client browser to cache the page but prevent proxy servers from caching the page.
The X-Powered-By: ASP.NET is there by default unless you remove it. I assume it is added as part of the HTTP Response pipeline just before the response is sent.
Check your IIS website header settings for your application. You can delete it there.
Edit: Based on your edit to your question, if the issue is that you want to remove the X-Powered-By HTTP header programmatically, you can do so if on IIS 7 and using the integrated pipeline. See https://web.archive.org/web/20210506093425/http://www.4guysfromrolla.com/articles/120209-1.aspx. See this section in the article:
Removing the Server HTTP Header The Server header is automatically added to the outgoing response by IIS. To remove this header from IIS 6 or IIS 7 you can use Microsoft's free UrlScan utility. If you are using IIS 7's integrated pipeline, you can alternatively remove the Server header programmatically by means of an HTTP Module. Stefan Grobner's blog entry, IIS 7 - How To Send A Custom "Server" HTTP Header, shows code that modifies the Server header. In a nutshell, you need to create an HTTP Module that creates an event handler for the PreSendRequestHeaders event. In that event handler you'd write code similar to the following to remove the Server header:
HttpContext.Current.Response.Headers.Remove("Server"); Howard von Rooijen has a similar, more in-depth account of removing the Server HTTP Header (and other identifying headers) via an HTTP Module when using IIS 7 and its integrated pipeline mode. See Cloaking your ASP.NET MVC Web Application on IIS 7 for more details.
It's from IIS. You can see it in the section HTTP Response Headers.
IIS is responsible for this. You can remove it here
This post explains where to change in IIS 6 & above
精彩评论