【发布时间】:2026-02-18 04:10:02
【问题描述】:
Get 请求正确显示了基本框架功能,但是当我尝试执行Post 时:
OnSubmit(evt)evt 是表单组; Chrome 调试器:
THEN 几行之后:(http 绑定到 httpclient)
实体框架 POST 代码:
// POST api/Registration/NewUser/<registration object>
[HttpPost]
[Route("NewUser")]
public string Post([FromBody]_Registration newUser)
{
var Id = Guid.NewGuid();
newUser.RegistrationId = Id.ToString(); << Good to here, but newUser is null
使用 Postman 发送一个虚拟记录,该记录进入 Post 函数。 计算了 Id,但 newUser 为 null,因此无法继续。
如何让它从请求的“正文”接收 NewUser?
【问题讨论】:
-
发布minimal reproducible example 作为文本。
-
你用的是HttpClient吗? (不是旧的已弃用的 http?)
标签: angular entity-framework-4 httpclient