Print Page | Close Window

Redirect

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=9303
Printed Date: 28 March 2026 at 11:06pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Redirect
Posted By: twooly
Subject: Redirect
Date Posted: 27 January 2004 at 10:56pm

Can someone tell me how to do a redirect in asp.net with variables in the redirect.  I know how to do it in plain asp but can't get it figured out.

I want to redirect with two varialbes

strOne, strTwo

       Response.Redirect "test2.aspx?ONE="& strOne"&"& strTwo




Replies:
Posted By: dpyers
Date Posted: 28 January 2004 at 1:36am
Response.Redirect "test2.aspx?ONE=" & strOne & "&" & strTwo

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: MorningZ
Date Posted: 28 January 2004 at 7:49am

plus in .NET you always have to have a set of parenthesis when calling a sub or function

Response.Redirect("test2.aspx?ONE=" & strOne & "&TWO=" & strTwo)



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: michael
Date Posted: 28 January 2004 at 9:13am
and if your parameters ought to be textboxes you have to put strOne.Text
just in case

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: Diep-Vriezer
Date Posted: 28 January 2004 at 1:16pm

Or create a custom parsing thing which looks a bit better (my opinion)

Response.Redirect("Test.aspx?" & strOne & "/" & strTwo)

/me likes doing some stuff different. Now you'll have to Split() the Request.ServerVariables("QUERY_STRING") and assing the variables back. A bit more work, but it 'looks' better.



-------------
Gone..


Posted By: Mart
Date Posted: 28 January 2004 at 1:23pm
Or
Dim strRedirect As String = String.Format("Test.aspx?{0}/{1}", var1, var2)

Response.Redirect(strRedirect)


Posted By: twooly
Date Posted: 28 January 2004 at 6:36pm
Awesome Thanks for the help.


Posted By: MadDog
Date Posted: 28 January 2004 at 6:57pm

I believe & is replaced with + in ASP.NET

At least + is what i use. Not sure if & works the same.



-------------
http://www.iportalx.net" rel="nofollow">


Posted By: Str8Dog
Date Posted: 28 January 2004 at 7:32pm
Using C# you would use a + dunno about VB.NET

-------------
http://www.str8dog.com/ - [IMG - http://www.str8dog.com/images/str8dog.gif -
I wasn't born with enough middle fingers.


Posted By: twooly
Date Posted: 28 January 2004 at 7:47pm
The & works fine for me on my page


Posted By: dpyers
Date Posted: 28 January 2004 at 9:56pm
Originally posted by Diep-Vriezer Diep-Vriezer wrote:

Or create a custom parsing thing which looks a bit better (my opinion)

Response.Redirect("Test.aspx?" & strOne & "/" & strTwo)

/me likes doing some stuff different. Now you'll have to Split() the Request.ServerVariables("QUERY_STRING") and assing the variables back. A bit more work, but it 'looks' better.

lol - you gotta get out more

I like mart's solution, but you get my vote for geek-of-the-week



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Diep-Vriezer
Date Posted: 29 January 2004 at 2:03am

..

BTW, + and & do the same thing. I use &, but I used +. Dunno why I changed.



-------------
Gone..


Posted By: Mart
Date Posted: 29 January 2004 at 4:31am
It depends what your doing weather to use & or plus....

Dim strSomething As Integer = 1 & 1

Will produce 11

Dim strSomething As Integer = 1 + 1

Will produce 2


Posted By: dpyers
Date Posted: 29 January 2004 at 6:45am
In some more strongly typed languages, variable1 + variable2 will also attempt to do the math. A habit of using math operands for math, and the & (AKA "and sign") for concatenation is just a way of avoiding trouble when you cross languages.

-------------

Lead me not into temptation... I know the short cut, follow me.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net