tags:

views:

261

answers:

2

I am looking for a well tested class for manipulating URLs in .NET. Specifically I want to be able to add/update querystring values given a url.

I have found various classes on the web that do this but none seem really robust and well tested. I also cannot find anything in the .NET framework; the Uri class doesn't let me manipulate the parameters in the querystring. There is code to do this in the framework but its all marked internal.

Is there a nice robust class around for working with Urls and QueryStrings?

+2  A: 

shouldn't a simple string Dictionary suffice for this? an ordinary ASP.NET query string is just composed of key-value pairs separated by ampersands.

cruizer
There are lots of special cases. For instance the urls in ASP.NET form tags don't have ampersands they are encoded as amp;
Brownie
Those special cases can all be handlded with httpserverutility.htmlencode and httpserverutility.htmldecode
Wayne
Thanks Wayne, that helped :-)
Brownie
A: 

Long time back we used SecureQueryString 2.0. since it inherits from NameValuePair (if I remember correctly), it provides ability to add, remove key values easily. It also provides support for encryption of the query if you want. It also provides ability to convert URL to NameValuePair and vice-versa.

Vivek