title: HttpWebRequest/HttpResponse: How to send data in the response?
body: <p>I have a client and a server.</p>
  
  <p>On the client side I have:</p>
  
  <pre><code>HttpWebRequest request = 
      (HttpWebRequest)WebRequest.Create("http://localhost/fa/Default.aspx");
  request.Method = "POST";                
  
  byte[] data = Encoding.ASCII.GetBytes(GetSAMLRequestB64());
  
  request.ContentType = "text/xml";
  request.ContentLength = data.Length;
  Stream stream = request.GetRequestStream();
  stream.Write(data, 0, data.Length);
  
  HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  Stream responseStream = response.GetResponseStream();
  </code></pre>
  
  <p>On the server side I have:</p>
  
  <pre><code>public void ProcessRequest(HttpContext httpContext) 
  {
      HttpResponse response = httpContext.Response;             
      response.Clear();
      response.BufferOutput = true;
      response.StatusCode = 200; // HttpStatusCode.OK;
      response.Write("Hello");
      response.ContentType = "text/xml";
      response.End();
  }
  </code></pre>
  
  <p>The client receives the response with the correct <code>StatusCode</code>. Although, if I do <code>(int)response.ContentLength;</code> on the client I get 0. I can't read the string "Hello" after I receive the response (client side). </p>