I am trying ASP.NET Core 3.1, MVC.
I am confused with the return type.
According to many links, such as https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-3.1&tabs=visual-studio we set our signature to include the return type
EG
public async Task<ActionResult<TodoItem>> GetTodoItem()
{
return new ToDoItem();
}
Historically I'd return a status code and the return object, such as
public async Task<ActionResult> GetToDoItem()
{
return Ok(new ToDoItem());
}
It's really unclear why we don't return the status code in this manner any more. It's possible I'm getting confused by WebApi and MVC controllers, but as I've read more into this, I believe there is no real difference (in that it's simply an exposed end point)
TtoActionResult<T>and the default status code for an action result is 200.