title: HttpListener Server Header c#
body: <p>I am trying to write a C# http server for a personal project, i am wondering how i can change the returned server header from Microsoft-HTTPAPI/2.0, to something else?</p>
  
  <pre><code> public class HttpWebServer
      {
          private HttpListener Listener;
  
          public void Start()
          {
              Listener = new HttpListener();
              Listener.Prefixes.Add("http://*:5555/");
              Listener.Start();
              Listener.BeginGetContext(ProcessRequest, Listener);
              Console.WriteLine("Connection Started");
          }
  
          public void Stop()
          {
              Listener.Stop();
          }
  
          private void ProcessRequest(IAsyncResult result)
          {
              HttpListener listener = (HttpListener)result.AsyncState;
              HttpListenerContext context = listener.EndGetContext(result);
  
              string responseString = "&lt;html&gt;Hello World&lt;/html&gt;";
              byte[] buffer = Encoding.UTF8.GetBytes(responseString);
  
              context.Response.ContentLength64 = buffer.Length;
              System.IO.Stream output = context.Response.OutputStream;
              output.Write(buffer, 0, buffer.Length);
              output.Close();
  
              Listener.BeginGetContext(ProcessRequest, Listener);
          }
      }
  </code></pre>