Is there a way to get all the querystring name/value pairs into a collection?

前端 未结 5 2051
傲寒
傲寒 2020-12-01 10:02

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

5条回答
  •  一生所求
    2020-12-01 10:57

    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]);
    }
    

提交回复
热议问题