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

后端 未结 7 667
臣服心动
臣服心动 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:30

    I suppose that you are using ASP.NET WebAPI and it bind all simple types (int, bool, string, etc) from URL and all complex types from body. When you marked name with FromBody attribute then it bind it from request body instead of url mapping.

    You can read more about ASP.NET WebAPI routing and parameter binding here:

    • On www.asp.net
    • On www.west-wind.com
    • and on MSDN

提交回复
热议问题