December 2019
Intermediate to advanced
510 pages
11h 33m
English
The Post action method is responsible for creating resources. Another principal responsibility of the Post action method is to tell the client where the resource is created and how to access it. This responsibility is usually implemented within the action method. ASP.NET Core provides two methods that can give this information to the client, which are CreatedAtAction and CreatedAtRoute. The following example shows how to use the CreatedAtAction method in our Post action:
... [HttpPost] public IActionResult Post(Order request) { var order = new Order() { Id = Guid.NewGuid(), ItemsIds = request.ItemsIds }; _orderRepository.Add(order); return CreatedAtAction(nameof(GetById), new { id = order.Id }, null); }...
After that, the ...
Read now
Unlock full access