Best way to convert query string to dictionary in C#

前端 未结 13 938
温柔的废话
温柔的废话 2020-12-24 04:28

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

13条回答
  •  自闭症患者
    2020-12-24 05:03

    Most simple:

    Dictionary parameters = new Dictionary();
    
    for (int i = 0; i < context.Request.QueryString.Count; i++)
    {
        parameters.Add(context.Request.QueryString.GetKey(i), context.Request.QueryString[i]);
    }
    

提交回复
热议问题