【发布时间】:2020-11-19 08:26:40
【问题描述】:
我有以下方法将多个对象发送到 .Net Core Web API
this.http.post('api/InternalReport/create', [
this.internalreport,
this.file]
, { observe: 'response', responseType: 'text' }).subscribe(data => {
if (data.status == 200) { console.log("success");}
}, err => { console.error('Observer got an error:');});
API 控制器
[HttpPost("create")]
public ActionResult<InternalReport> Create([FromBody]InternalReport report,[FromBody]File file)
{
try
{
_internalreportService.Create(report);
_fileservice.Update(file.sha1,file);
return Ok("success");
}
catch (Exception e)
{
return NotFound();
}
}
但是在控制器端这两个对象都是空的。
【问题讨论】:
标签: c# typescript angular8 asp.net-core-webapi