I am using Redirect with the GET method, like this (works fine):
Response.Redirect(string.Format("../NewPage.aspx?Name1={0}&Name2={1}","name1", "name2" );
But I would like to use the POST method, so the client does not have access to these variables. I searched and found " Response.Redirect with POST instead of Get? "
I currently have the following code snippet as described:
StringBuilder postData = new StringBuilder();
postData.Append("Name1=" + HttpUtility.UrlEncode("Name1") + "&");
postData.Append("Name2=" + HttpUtility.UrlEncode("Name2"));
StreamWriter writer = null;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postData.ToString().Length;
try
{
writer = new StreamWriter(request.GetRequestStream());
writer.Write(postData.ToString());
}
finally
{
if (writer != null)
writer.Close();
}
Response.Redirect("~/NewPage.aspx");
My question is, how can I use / get the passed variables in the NewPage.aspx page?
Thanks for any help.
source
share