views:

483

answers:

2

Is there a way to url encode the entire URL querystring without trying to urlencode each individual querystring parameters. Right now I'm having to rebuild the querystring with something like this:

foreach (string x in Page.Request.QueryString.Keys)
{
 sQueryString += x + "=" + Server.UrlEncode(Request.Params.Get(x)) + "&";
}
+3  A: 
Alex
Nissan Fan
No need to perform UrlEncode on it.
Alex
There is no .Query but this seems to work perfectly: Page.Request.Url.AbsoluteUri
Tim Boland
@Tim Boland: yep, sure ;)
Alex
A: 

Other than using string.Format and you having an extra & at the end of your QueryString the approach above is optimal.

Nissan Fan