title: Redirect to an URL from httpwebresponse Location header
body: <p>Im trying to redirect my ASP.NET page on it load to redirect to another page, whose URL i would get from the response of an HTTP post.</p>
  
  <pre><code>HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
  
  StringBuilder postData = new StringBuilder();
  postData.Append("xmldata=" + HttpUtility.UrlEncode(xdoc));
  postData.Append("&amp;signature=" +HttpUtility.UrlEncode(signature));
  httpWebRequest.Method = "POST";
  httpWebRequest.Accept = "*/*";
  httpWebRequest.ContentType = "application/x-www-form-urlencoded";
  using (Stream requestStream = httpWebRequest.GetRequestStream())
  {
      using (MemoryStream ms = new MemoryStream())
      {
          using (BinaryWriter bw = new BinaryWriter(ms))
          {
              bw.Write(Encoding.UTF8.GetBytes(postData.ToString()));
              ms.WriteTo(requestStream);
          }
      }
  }
  httpWebRequest.AllowAutoRedirect = false;
  var returnURL="";
  using (HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse())
  {
      httpStatusCode = httpWebResponse.StatusCode;
       if (httpStatusCode == HttpStatusCode.Found)
       {
          returnURL= httpWebResponse.Headers["Location"].ToString();
       }
  }
  
  Response.Redirect(returnURL);
  </code></pre>
  
  <p>This response redirect ends in 404 error. Please help</p>