Solved

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

Posted on 2012-04-11
4
255 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP:DataGrid and how to bind to a BoundColumn 8 37
JavaScript error 1 52
SQL best practice question 3 36
Resolve Dependency Issues 4 41
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

929 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now