Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

BuildQueryString with FriendlyUrls (CMS 5)

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?

May 19, 2009 9:56

I've used the BuildQueryString method without any problems.

What is the value of your redirect string?

May 19, 2009 10:32

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

My redirect string from the code above looks like this:


As you can see it's wrong :-)

May 19, 2009 10:44

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.

May 19, 2009 11:05
Tack! Funkar perfekt!
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.