title: ASP HttpWebRequest and Redirect
body: <p>OK, I have a client doing a POST to a server with some data. The server receives the post, and answers with a redirect. The problem is that the client does not redirects. Also, I've tried to check the StatusCode of the response the client gets, and it is always the same "OK". Instead of the redirect code. What am I missing?</p>
  
  <p>In the client side I have something like this:</p>
  
  <pre><code>  StringBuilder sb;
          try
          {
              HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost/serv/Default.aspx");
              request.Method = "POST";                
  
          byte[] data = Encoding.ASCII.GetBytes(GetDATA());
  
          request.ContentType = "text/xml";
          request.ContentLength = data.Length;
          Stream stream = request.GetRequestStream();
          stream.Write(data, 0, data.Length);
  
          request.AllowAutoRedirect = true;
          request.MaximumAutomaticRedirections = 10;
  
          HttpWebResponse response = (HttpWebResponse) request.GetResponse();
              response.Close(); } catch(Exception ex) {}
  </code></pre>
  
  <p>In the server side I have just this line:</p>
  
  <pre><code>HttpContext.Current.Response.Redirect("http://www.google.com", true);
  </code></pre>
  
  <p>In this case, the client receives an answer and does not do nothing.</p>
  
  <p>Thanks.</p>