ASP.net redirect message?

Basically, I want to take a URLString and pull out all the variables and their values ​​and send them to another page with a redirect to the taht page. How can I remove this without having the form and suppression of filing, etc ....

This is what I got.

   string url = "http://www.blah.com/xyz.aspx";


        StringBuilder postData = new StringBuilder();

        postData.Append("CustomerID=" + HttpUtility.UrlEncode("Hello Rico") + "&");
        postData.Append("FirstName=" + HttpUtility.UrlEncode("HelloFirstName"));
        //ETC for all Form Elements    

        // Now to Send Data.    
        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());
            writer.Flush();

            HttpWebResponse WebResp = (HttpWebResponse)request.GetResponse();

            //Now, we read the response (the string), and output it.   
            Stream Answer = WebResp.GetResponseStream();
            StreamReader _Answer = new StreamReader(Answer);
            Response.Write(_Answer.ReadToEnd());

        }
        finally
        {
            if (writer != null)
                writer.Close();
        }   
+5
source share
3 answers

, html- , . URL, . asp.net, "", , querystring, , , .

, - , " ". http, . , , .

+2
+1

What do you need on the page to which you redirect the user? Your best option is to use session variables to transfer data between pages to Redirect, unless you save the form that was originally submitted to the page.

To add information to a session element, you can use the following code:

Session.Item("CustomerID") = "CustomerID=" & ID.ToString
0
source

All Articles