I am trying to acces post data in an ashx webhandler, in an MVC project I used Newtonsoft.Json to achieve this.
Dictionary<string, string> postData = JsonConvert.DeserializeObject<Dictionary<string, string>>(data);
this resulted in a dictionary where i can acces the post data with
if (postData.ContainsKey("myKey"))
{
someVar = postData["myKey"];
}
In another project ASP.NET 3.5 I don't seem to have Newtonsoft available and I try to use:
object postData = new JavaScriptSerializer().DeserializeObject(data);
This method is supposed to return an object graph, and it seems to work fine, if I look with debugger in visual studio, I can see the data that I posted:
How can I access the data in this object?, if I type postData. the only options i get are: Equals, GetHashCode, GetType and ToString
I tried postData[0].value;
but this gives an error: cannot apply indexing.
DeserializeObject
outputs a dictionary, so you should be able to do this: