title: Handling post requests in HttpListener
body: <pre><code>private void ListenerCallback(IAsyncResult ar)
          {
              _busy.WaitOne();
              try
              {
                  HttpListenerContext context;
                  try
                  { context = _listener.EndGetContext(ar); }
                  catch (HttpListenerException)
                  { return; }
  
                  if (_stop.WaitOne(0, false))
                      return;
  
                  var sr = new StreamReader(context.Request.InputStream);
                  string x = sr.ReadToEnd();
                  Console.WriteLine("{0} {1}", context.Request.HttpMethod, x);
                  //context.Response.SendChunked = true;
                  using (TextWriter tw = new StreamWriter(context.Response.OutputStream))
                  {
                      //for (int i = 0; i &lt; 5; i++)
                      {
                          //tw.WriteLine("&lt;p&gt;{0} @ {1}&lt;/p&gt;", i, DateTime.Now);
                          tw.WriteLine("&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;");
                          tw.WriteLine("Server Response");
                          tw.WriteLine("&lt;/body&gt;&lt;/html&gt;");
                          tw.Flush(); //Catch http exception if client exists halfway through
                          //Thread.Sleep(1000);
                      }
                  }
              }
              finally
              {
                  if (_maxThreads == 1 + _busy.Release())
                      _idle.Set();
              }
          }
  </code></pre>
  
  <p>Above is my code, I can go to the URL with Chrome and few the reply even though the server shows it takes 2 get requests, I want to be able to handle POST requests, when I send a post request it reads it properly but the client doesn't get the reply.</p>