Redirect page and pass the string to that page as well.

I want to redirect a page and also pass a string to that web page as well.

Thanks for the advice.
Response.Redirect("~/admin/test.aspx?UserName=" + Server.UrlEncode(UserName), false);
                                    Response.Redirect("~/admin/test.aspx");

Open in new window

Is it correct?
zhshqzycAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
BuggyCoderConnect With a Mentor Commented:
a better approach would be:-

Server.Transfer(string.Format("~/admin/test.aspx?UserName={0}",Server.UrlEncode(UserName));
This will ensure only one round trip to server side.

Read more here:-
http://www.dotnetfunda.com/articles/article164.aspx
0
 
binaryevoCommented:
Line 1 looks fine to me.  This will redirect you to the appropriate page and append the querystring appropriately.
0
 
zhshqzycAuthor Commented:
But if there is only line 1, it doesn't jump the new page because of "false". If set "true" I will get an exception.
0
 
binaryevoCommented:
Use server.transfer... Its a better option much of the time.  See below:

http://arplis.com/difference-between-server-transfer-and-response-redirect/
0
All Courses

From novice to tech pro — start learning today.