Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

BuildQueryString with FriendlyUrls (CMS 5)

Vote:
 
I'm having a bit of a problem regarding the UriSupport.BuildQueryString method.  I have this link to which I want to add three parameters. I do the following:

NameValueCollection myCol = new NameValueCollection();

            myCol.Add("Comment", "false");

            myCol.Add("EditMode", "true");

string redirect = CurrentPage.LinkURL + UriSupport.BuildQueryString(myCol);

When I click my link the page can't be displayed. I've altered the code above several times but with no luck. Does anybody have any solutions to my problem?

#29847
May 19, 2009 9:56
Vote:
 

I've used the BuildQueryString method without any problems.

What is the value of your redirect string?

#29848
May 19, 2009 10:32
Vote:
 

Ok, dp you have any sample code I can look at?

My redirect string from the code above looks like this:

"/templates/pages/MyPage.aspx?id=516&epslanguage=svComment=false&EditMode=true"

As you can see it's wrong :-)

#29849
May 19, 2009 10:44
Vote:
 

I would use an UrlBuilder instead.

UrlBuilder ub = new UrlBuilder(CurrentPage.LinkURL);
ub.QueryCollection.Add("parameter1", "value1");
ub.QueryCollection.Add("parameter2", "value2");
Response.Redirect(ub.ToString(), true);

 The problem with your approach is that you append the correctly built "BuildQueryString", but you miss the "&"/"?" between the strings when you just concat them.

#29852
May 19, 2009 11:05
Vote:
 
Tack! Funkar perfekt!
#29867
May 19, 2009 15:33
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.