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.
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
StringBuilder postData = new StringBuilder();
postData.Append("xmldata=" + HttpUtility.UrlEncode(xdoc));
postData.Append("&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);
This response redirect ends in 404 error. Please help