Methods for receiving JSON data in an Asp.NET core Controller

  1. [HttpPost] 
    public  IActionResult Fill([FromBody] dynamic data)
    {
         string amount = data.amount.GetString();
    }
    
  2.  [HttpPost] 
     public  IActionResult Fill()
     {
          string dataStr = new StreamReader(Request.Body, Encoding.UTF8).ReadToEnd();
          var data = JObject.Parse(dataStr);
          string amount = data.value.amount;
     }
    
  3. [HttpPost] 
    public  IActionResult Fill([FromBody] YourType data)
    {
        string amount = data.amount;
    }
    

First post

I just finished the installation for the Chryp lite blog system. I met a small issue related to its compatibility with MySQL version 8 but I managed to resolve it. Happy!

The issue is that "groups" word has become a reserved keyword in MySQL 8.x, and unfortunately, there's a table in this blog system named "groups" too. I first tried to use "``" to encapsulate the table name and I failed quickly because there are too many places using the table name.

Fortunately, the install program supports me to add a table prefix for all tables. So it was resolved by simply adding a table prefix!

Happy!