In my asp.net c# solution, I want to get a dictionary of all the url parameters, where the key is the parameter name and the value is the parameter value. How can I do this?
Thanks.
In my asp.net c# solution, I want to get a dictionary of all the url parameters, where the key is the parameter name and the value is the parameter value. How can I do this?
Thanks.
I often get into the same problem. I always end up doing it like this:
This gives all params for the request, including QueryString, Body, ServerVariables and Cookie variables. For only QueryString do this:
The
HttpRequest.QueryString
object is already a collection. Basically a NameValueCollection. Check here for a more detailed explanation on MSDN. To convert this collection in to a dictionary you could add an extension method as follows.Then you could basically just do the following since Request.QueryString is basically a NameValueCollection
You need HttpUtility.ParseQueryString
you can use this to get the querystring value itself:
To put it together
More info at http://msdn.microsoft.com/en-us/library/ms150046.aspx
The harder manual way without using the builtin method is this: