【发布时间】:2020-12-07 07:50:11
【问题描述】:
这是在添加控制器时插入VS2019生成的记录的功能:
// POST: api/Students
[HttpPost]
public async Task<ActionResult<Student>> PostStudent(Student student)
{
_context.Students.Add(student);
await _context.SaveChangesAsync();
return CreatedAtAction("GetStudent", new { id = student.Id }, student);
}
我不明白为什么它使用CreatedAtAction返回student,为什么不直接返回对象return student;?
【问题讨论】:
标签: asp.net asp.net-core asp.net-web-api