title: Can't send POST in C#
body: <p>I have the following problem.
  I have the method that sends json via POST:</p>
  
  <pre><code>public string request (string handler, string data) 
  {
      WebRequest request = WebRequest.Create(baseUri + "/?h=" + handler);
      request.Method = "POST";
      request.ContentType = "text/json";
  
      string json = "json=" + data;
      byte[] bytes = Encoding.ASCII.GetBytes(json);
      request.ContentLength = bytes.Length;
  
      Stream str = request.GetRequestStream();
      str.Write(bytes, 0, bytes.Length);
      str.Close();
  
      WebResponse res = request.GetResponse();
      StreamReader sr = new StreamReader(res.GetResponseStream());
      lastResponse = sr.ReadToEnd();
      return lastResponse;
  }
  </code></pre>
  
  <p>When using the method on the server does not come data in POST. As if this code is not executed.</p>
  
  <pre><code>Stream str = request.GetRequestStream();
  str.Write(bytes, 0, bytes.Length);
  str.Close();
  </code></pre>
  
  <p>On the server i'm using following php script for debug:</p>
  
  <pre><code>&lt;?php print_r($_POST); ?&gt;
  </code></pre>
  
  <p>Also tried to write to the stream as follows:</p>
  
  <pre><code>StreamWriter strw = new StreamWriter(request.GetRequestStream());
  strw.Write(json);
  strw.Close();
  </code></pre>
  
  <p>The result - a zero response. In response comes an empty array.</p>