Getting Post Data

Get Post Data Values Async
dynamic obj = await Request.Content.ReadAsAsync<JObject>();
            var username = obj.username;
            var password = obj.password;

            var result = DoSomething(username.Value, password.Value);
Option: Posting in data=string

Post data in the format of "data=string", you will need to create complex type:

  • Create a new class:
public class MyFormData
    public string Data { get; set; }
  • Update Controller:
public void Post(MyFormData formData)
    //your JSON string will be in formData.Data
Option: Not Asynchronously

Autoparse using parameter binding
Dynamic is made up of JToken, so the the .Value accessor must be used

public void Post([FromBody]dynamic value) {
    var x = value.var1.Value; // JToken