Angular2 HTTP Post ASP.NET MVC Web API

前端 未结 7 1846
栀梦
栀梦 2020-12-06 11:23

How do you properly create a Web API POST of complex object or multiple parameters using Angular2?

I have a service component in Angular2 as seen below:



        
7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-06 12:01

    WebAPI does not provide this out of the box. If you try to get understanding of web API bindings, you might be able to figure out why.

    I think this article might help.

    The generic rules are:

    – simple, string-convertible parameters (value types, strings, Guids, DateTimes and so on) are by default read from URI

    – complex types are by default read from the body

    – collections of simple parameters are by default read from the body too

    – you cannot compose a single model based on input from both URI and request body, it has to be one or the other

提交回复
热议问题