【发布时间】:2019-09-30 00:04:21
【问题描述】:
我在上传文件并将其转换为 json 并传递给我的 .net 核心 webapi 控制器时收到错误请求。
这里是一个错误截图。我也对模型进行了控制台。
这是我的打字稿代码
const httpHeaders = new HttpHeaders({
'Content-Type': 'application/json',
});
var approval = {
...this.MemberApproval,
};
console.log(JSON.stringify(approval));
return this.http.post(this.Url + '/Member/UpdateMember/update', JSON.stringify(approval), { headers: httpHeaders });
在 .net core webapi 上,我正在这样做。
我的模特:
public class MemberApproval
{
public string Notes;
public IFormCollection Attachment;
public int ApprovalStatus;
public int SubsId;
public int MemberId;
}
我的控制器:
[Route("[action]/{item}")]
[HttpPost]
public IActionResult UpdateMember([FromBody]MemberApproval approval )
{
if (approval !=null)
{
_repo.UpdateMemberStatus(approval);
}
return Ok();
}
【问题讨论】:
-
将其标记为可能重复。在这里stackoverflow.com/questions/52032438/… 和stackoverflow.com/questions/54424712/… 在这里提出并回答了同样的问题
标签: javascript c# angular typescript asp.net-core