Custom Querystring

The article on manipulating the query string, which I discussed here, has moved to a new site, and today I noticed, that one statement was not completely correct, but only when I debugged one of my projects.

The NameValueCollection.ToString() only returns the class name, which is the default ToString() behavior.

According to the MSDN documentation, HttpUtility.ParseQueryString() returns a NameValueCollection, but it really is a HTTPValueCollection, which is itself derived from NameValueCollection.

You can create a HTTPValueCollection only through the ParseQueryString() method. However, the big advantage of this class is that the ToString() method is overwritten and returns the key/value pairs in URL notation, i.e. key1=value1&key2=value2 etc.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: