title: Use of HttpListener
body: <p>I have the following HTTP listener method, greatly inspired by MSDN's example use of the HttpListener class. I'm fairly new to programming and I'm not sure where to go from here to initialize it from my Main(). Any suggestions?</p>
  
  <pre><code> public static void HttpListener(string[] prefixes)
      {
          if (prefixes == null || prefixes.Length == 0)
              throw new ArgumentException("Prefixes needed");
  
          HttpListener listener = new HttpListener();
  
          foreach (string s in prefixes)
          {
              listener.Prefixes.Add(s);
          }
          listener.Start();
          Console.WriteLine("Listening..");
  
          HttpListenerContext context = listener.GetContext();
          HttpListenerRequest request = context.Request;
          HttpListenerResponse response = context.Response;
  
          string responseString = "&lt;HTML&gt;&lt;BODY&gt; Test &lt;/BODY&gt;&lt;/HTML&gt;";
          byte[] buffer = Encoding.UTF8.GetBytes(responseString);
  
          response.ContentLength64 = buffer.Length;
          Stream output = response.OutputStream;
          output.Write(buffer, 0, buffer.Length);
  
          output.Close();
          listener.Stop();
      }
  </code></pre>