Ross
Ross

Reputation: 112

C# ASP Response.Redirect URL Parameter being moved in output URL

I'm using Response.Redirect to to refresh a page with a parameter appended to the end of the URL but for some reason the parameter is being moved to a different part of the URL.

Here's an example, my URL is http://domain.com/en/members/careers/vacancies/?output=html

I want this URL to refresh with the following: http://domain.com/en/members/careers/vacancies/?output=html&param=1

I want to include the extra parameter so I used the following function:

string url = CurrentPage.LinkURL;
Response.Redirect(url+"?output=html&param=1");

Yet when the page refreshes it has redirected to the following URL: http://domain.com/en/?output=html/members/careers/vacancies/

I have no idea why the the output parameter is being put there after /en/ or where my second parameter has gone.

I've been at this for a few hours and I'm going crazy looking at it, any suggestions on this would be greatly appreciated. Thanks!

Upvotes: 0

Views: 1801

Answers (1)

Damian Hoffmann
Damian Hoffmann

Reputation: 36

Maybe try this instead of CurrentPage.LinkURL. Also in you Response.Redirect take out the "?output=html" as it will already be in your string

string URL = System.Web.HttpContext.Current.Request.Url.AbsoluteUri;
Response.Redirect(URL + "&param=1");

Upvotes: 1

Related Questions