如何将数组从 Angular 发送到 HttpPost 到 .Net Framework(ApiController)?

How to send array to HttpPost from Angular to .Net Framework(ApiController)?

我正在尝试将 Angular 数组数据发送到 .Net Framework 服务器端

我当前的代码如下:

Angular: 下面的代码

service.ts

   addRecipient(val:any)
    {
      return this.http.post(this.APIUrl+'/recipient',val);
    }

recipient.ts

SendSurveyList: any = []; - 声明列表

this.SendSurveyList.push(val);-推送结果

通过服务器发送结果: ->

  this.service.addRecipient(this.SendSurveyList).subscribe(res=>
        {
          alert(res.toString() + "Was Sent");
        });

.Net Framework: 代码如下

 // POST api/values
        [HttpPost]
        public HttpResponseMessage Post([FromBody]Recipient postRecipient)
        {
        }
  1. 当前结果:HttpPost 返回 null;
  2. 预期结果:HttPost 返回 SendSurveyList 列表数据。

我的想法:

我有个想法把service.ts边posturl改成喜欢:

 addRecipient():Observable<any[]>
    {
      return this.http.post(this.APIUrl+'/recipients');
    }

但是这个只对http.GET这边有效~其实我不知道怎么从http.Post实现。

I am also looking forward to your ideas. Since I managed to implement Post for a single record. But I would like to do it for List / Array data throug.

// POST api/values
        [HttpPost]
        public HttpResponseMessage Post([FromBody]List<Recipient> listPostRecipient)
        {
        }