Search code examples
c#arraysdatatablesashx

C# generic handler query string parameters in array


I have a query string which is in array format, and im trying to figure out how I would access the sub elements using Context.Request

heres an example of my query string params

QueryString

    draw                          1
    search[value]                 test

and so in my C# generic handler (ashx) code I modeled after something i would do in PHP or Coldfusion I did the following

if (context.Request["search"]["value"] != "") {
 for (int i = 0; i < columns.Count; i++) ...
}

i get the following error

error CS1502: The best overloaded method match for 'string.this[int]' has some invalid arguments

Any idea how i write this piece?


Solution

  • this is how i ended up accessing the query string arrays

    var searchString = context.Request["search[value]"];
    
    var sortColumnIndex = Convert.ToInt32(context.Request["order[0][column]"]);
    var sortDirection = context.Request["order[0][dir]"]; // asc or desc