At the moment my web app accepts post request fine. But I'm trying to read all the properties that are passed through to the object and then resend that object with a couple of properties changed. I'm having trouble viewing
the object properties. Usual JSON objects are sent as a string and I can see all the properties that sent. Is there a way to see all the properties of an encoded JSON object?
I've tried examples from How to Get the HTTP Post data in C#?
public ActionResult Post(object value)
{
string[] keys = Request.Form.AllKeys;
for (int i= 0; i < keys.Length; i++)
{
Response.Write(keys[i] + ": " + Request.Form[keys[i]] + "<br>");
}
return new HttpStatusCodeResult(200);
}
But I get a compiler error indicating that HttpRequestMessage
does not contain a definition for 'Form'.
I also tried Request.Form["payload"]; or Request["payload"] then i am presented with the error Cannot applying indexing to an expression of type 'HttpRequestMessage'
I would like to know the properties that are sent before I create the class. Do I have to create the class first then cast it to the object?