AJAX & Web Api Post Method - How does it work?

后端 未结 7 666
臣服心动
臣服心动 2020-12-13 14:24

I am trying to write to my database using AJAX / Jquery and c#. Whenever I pass the parameter in to the C# code it shows as null. I am using the default template that visual

7条回答
  •  我在风中等你
    2020-12-13 15:18

    Binding in API controllers is a little on the strange side. I believe:

    public void Post([FromBody]RecipeInformation information)
    

    with

    var dataJSON = { name: "test" };
    

    should work, and will definitely work if you just pass it as form data.

提交回复
热议问题