1

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 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

There are lots of special cases. For instance the urls in ASP.NET form tags don't have ampersands they are encoded as amp;
Those special cases can all be handlded with httpserverutility.htmlencode and httpserverutility.htmldecode
This is bad advice. "key-value pairs separated by ampersands and a dictionary?" Keep in mind, you can have multiple parameters with the same name.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.