I've been following along with a tutorial here to get my head around authentication in Web API with OAuth.
I have worked on Web API before, where I named the methods to start with Get, Put, Post etc. in order that they were routed to depending on the http verb. I also know that actions can be decorated with attributes ([HttpGet] etc) to denote the verb that maps to them.
In the tutorial, there is an action on a controller that looks like this:
// POST api/Account/Register
[AllowAnonymous]
[Route("Register")]
public async Task<IHttpActionResult> Register(UserModel userModel)
{
if (!ModelState.IsValid)
return BadRequest(ModelState);
IdentityResult result = await _repo.RegisterUser(userModel);
IHttpActionResult errorResult = GetErrorResult(result);
if(errorResult != null)
return errorResult;
return Ok();
}
This method, as the comment suggests, responds to POST requests. I cannot see how the Web API knows that this action is for POST. Can anyone enlighten me?