Solved

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

Posted on 2012-04-11
4
258 Views
Last Modified: 2012-04-11
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?
0
Comment
Question by:zhshqzyc
  • 2
4 Comments
 
LVL 14

Expert Comment

by:binaryevo
ID: 37834843
Line 1 looks fine to me.  This will redirect you to the appropriate page and append the querystring appropriately.
0
 

Author Comment

by:zhshqzyc
ID: 37834860
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
 
LVL 14

Expert Comment

by:binaryevo
ID: 37834883
Use server.transfer... Its a better option much of the time.  See below:

http://arplis.com/difference-between-server-transfer-and-response-redirect/
0
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
ID: 37834895
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

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question