I trying to send Angular array data to .Net Framework server side
My current code looks like:
Angular: code below
service.ts
addRecipient(val:any)
{
return this.http.post(this.APIUrl '/recipient',val);
}
recipient.ts
SendSurveyList: any = [];
- declared list
this.SendSurveyList.push(val);
- pushing results
Sending results via server: ->
this.service.addRecipient(this.SendSurveyList).subscribe(res=>
{
alert(res.toString() "Was Sent");
});
.Net Framework: code below
// POST api/values
[HttpPost]
public HttpResponseMessage Post([FromBody]Recipient postRecipient)
{
}
- Current Result: HttpPost returning null;
- Expecting result: HttPost returning SendSurveyList list data.
My idea:
I have an idea to change service.ts side post url to like:
addRecipient():Observable<any[]>
{
return this.http.post(this.APIUrl '/recipients');
}
But this is valid only for http.GET side ~ I don't actually know how to realize it from 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.
CodePudding user response:
// POST api/values
[HttpPost]
public HttpResponseMessage Post([FromBody]List<Recipient> listPostRecipient)
{
}