title: Remove server tag from http response header
body: <p>I am trying to remove server tag from http response headers in asp.net(C#)
  With the help of stack overflow, I succeeded to create .dll file and added its reference in my project but still the server tag is visible in http headers. Below is the code for my .dll file.</p>
  
  <pre><code>using System;
  using System.Web;
  namespace ServerHeaders
  {
  public class CustomServerHeaderModule : IHttpModule
  {
      public void Init(HttpApplication context)
      {
          context.PreSendRequestHeaders += OnPreSendRequestHeaders;
      }
      public void Dispose() { }
      static void OnPreSendRequestHeaders(object sender, EventArgs e)
      {
          // remove the "Server" Http Header
          HttpContext.Current.Response.Headers.Remove("Server");
  
      }
  }
  }
  </code></pre>
  
  <p>I have added reference to this file in web site and added required tag in web.config which is as below.</p>
  
  <pre><code>&lt;configuration&gt;
  &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.0"/&gt;
  &lt;httpRuntime enableVersionHeader="false" /&gt;
  &lt;httpModules&gt;
    &lt;add name="CustomServerHeaderModule1" type="ServerHeaders.CustomServerHeaderModule" /&gt;
  &lt;/httpModules&gt;
  &lt;/system.web&gt;
  
  &lt;system.serviceModel&gt;
      &lt;bindings/&gt;
      &lt;client/&gt;
  &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Please guide me now what is still missing or is there any error?
  I have fixed the error in <code>web.config</code>. Now it shows error in module at        </p>
  
  <pre><code>HttpContext.Current.Response.Headers.Remove("Server");
  </code></pre>
  
  <p>The error is object reference is not set to an instance of the object. How to solve this error? I am running the project from local host(Using <kbd>F5</kbd>).</p>