As part of an effort to make our API and site more secure, I\'m removing headers that leak information about what the site is running.
Example before stripping headers:<
The same way that's in this answer, and in this website:, you should use the following steps:
C#:
namespace MvcExtensions.Infrastructure
{
public class CustomServerName : IHttpModule
{
public void Init(HttpApplication context)
{
context.PreSendRequestHeaders += OnPreSendRequestHeaders;
}
public void Dispose() { }
void OnPreSendRequestHeaders(object sender, EventArgs e)
{
HttpContext.Current.Response.Headers.Remove("Server");
}
}
}
Web.config: