Is there a way to get all the querystring name/value pairs into a collection?
Is there a way to get all the querystring name/value pairs into a collection?
I'm looking for a built in way in .net, if not I can just split on the & and load a collection.
Solution 1:
Yes, use the HttpRequest.QueryString
collection:
Gets the collection of HTTP query string variables.
You can use it like this:
foreach (String key in Request.QueryString.AllKeys)
{
Response.Write("Key: " + key + " Value: " + Request.QueryString[key]);
}
Solution 2:
Well, Request.QueryString
already IS a collection. Specifically, it's a NameValueCollection
. If your code is running in ASP.NET, that's all you need.
So to answer your question: Yes, there is.