Angular2 HTTP Post ASP.NET MVC Web API

前端 未结 7 1841
栀梦
栀梦 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 11:50

    WebApi will be able to deserialize your Credential object provided the JSON object has the same field names (I am not sure about case so you may be right here). You seem to be missing the headers from the post call in your Angular2 component.

    Can you check the Content-Type using Chrome Debugger or Fiddler? It should be application/json.

提交回复
热议问题