Solved

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

Posted on 2012-04-11
4
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

617 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