Hi,
I'm looking for the simplest way of converting a query string from an HTTP GET request into a Dictionary, and back again.
I figure it's easier to carry out various manipulations on the query once it is in dictionary form, but I seem to have a lot of code just to do the conversion. Any recommended ways?
From stackoverflow
-
How about
HttpUtility.ParseQueryString?Just add a reference to System.Web.dll
-
HttpUtility.ParseQueryString()parses query string into aNameValueCollectionobject, converting the latter to anIDictionary<string, string>is a matter of a simpleforeach. This, however, might be unnecessary sinceNameValueCollectionhas an indexer, so it behaves pretty much like a dictionary.
0 comments:
Post a Comment