Is there a default verb applied to a Web API ApiController method?

I’ve been looking at the code (in from this article:

It’s pretty good and seems to work fine. There are very few articles that explain this kind of token authentication, but this is the best I’ve seen. Note that I’m new to this technology and there’s much to learn.

So, I noticed that the UsersController has this code:

public class UsersController : ApiController
    public Status Authenticate(User user)
        . . .

The Authenticate method doesn’t start with a known HTTP verb, e.g. Get or Post, and there’s no [HttpGet] or [HttpPost] attribute associated with this method, so how does the controller know with which verb to associate this method? Just by looking at the code, how can I tell which verb I need to use? Is there such a thing as a “default” verb if nothing matches?

By the way, in case you’re wondering, the only verb that works is POST. I’d love to understand why that is the case.


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

File this under learning something new every day!

Typically method name matching is thought of this way. Looking at the WebAPI source, however, there is a branch of logic for fallback. If the method name doesn’t map (through attribute, or convention) to a supported HTTP verb, then the default is POST.

By default action selection happens through ReflectedHttpActionDescriptor class. The important method here is GetSupportedHttpMethods(). In relevant part the code reads:

        if (supportedHttpMethods.Count == 0)
            // Use POST as the default HttpMethod

You can see the full source here (around the middle of the file).

Method 2

In this special case, the default Http Verb is POST. In other scenarios, the default verb depends on the name of the action and other factors. Below is the algorithm quoted from

HTTP Methods. The framework only chooses actions that match the HTTP
method of the request, determined as follows:

  1. You can specify the HTTP method with an attribute: AcceptVerbs, HttpDelete, HttpGet, HttpHead, HttpOptions, HttpPatch, HttpPost, or
  2. Otherwise, if the name of the action (controller method) starts with “Get”, “Post”, “Put”, “Delete”, “Head”, “Options”, or
    “Patch”, then by convention the action supports that HTTP method.
  3. If none of the above, the method supports POST.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x