Avatar of endrec
 asked on

How to Use Response.Redirect and Pass/Keep All Existing Querystring Parameters In The Redirect

I wanted to know if there is a way to redirect the user from one page to another, but keep all the existing querystring parameters in the original page request.

Example:  User is on the URL domain.com/folder/page.aspx?key1=1&key2=yes&key3=456534234-5445435 and some action needs to redirect the user to domain2.com/folder2/page2.aspx but also pass all the existing querystring variables as the number of querystring variables in page.aspx differs occasionally (e.g. not always three querystring variables).  So the final redirect would take the user to domain2.com/folder2/page2.aspx?key1=1&key2=yes&key3=456534234-5445435 in the example.
.NET ProgrammingASP.NETC#

Avatar of undefined
Last Comment

8/22/2022 - Mon

ya you can pass the query string variables in the Response.Redirect


Ok, what if the number and value for the querystring variables is dynamic, e.g. how do I get all the querystring variables for the current page and include that in the redirect request to another page?  That's the question I'm hoping to get some aid with.

I'm trying to get the querystring variables for the current page then append them to the redirect to another page at some point (e.g. user clicks a particular button, some particular logic is executed).
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck

Response.Redirect("domain2.com/folder2/page2.aspx?" + Request.QueryString.ToString());

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Hmmm... My solution does exactly what you asked, doesn't it? :)