Better support for HEAD, OPTIONS, and PATCH http verbs

Mar 29, 2012 at 12:23 AM

We have a number of issues and/or pull requests related to adding better support for the HEAD, OPTIONS, and PATCH verbs. Since they are all related, let's have one place to discuss what's needed.

Better support means

  • Add a new entry to the HttpVerbs enumeration (if not already there).
  • Add a new HttpMethodAttribute to match existing attributes such as [HttpPost] or [HttpGet]

In addition, ensure that all APIs that consume the HttpVerbs enum values as well as http methods as strings are updated to be aware of the new entries. This includes:

  • AcceptVerbsAttribute.EnumToArray()
  • HtmlHelper.HttpMethodOverride() - including the override that accepts a string representation
  • HttpRequestBaseExtensions.IsHttpMethod - from Microsoft.Web.Mvc project

These changes should enable both receiving (and filtering) requests based on verb as well as generating forms that can use the verb override mechanism to issue requests from a browser.

Mar 30, 2012 at 1:46 AM

I'd much rather see a HttpMethodAttribute added where actual method is just a string parameter.  It doesn't make sense to me to create a new attribute for all the methods.  Especially once someone discovers the WebDAV methods.  And the WebAPI approach of deriving from the HttpMethod class is easily extensible if someone wants to support other methods.

Mar 30, 2012 at 1:52 AM


there already exists AcceptVerbsAttribute which allows you to provide arbitrary strings. These new attributes would be mostly for convenience/discoverability. We certainly arn't going to create a new attribute for every conceivable HTTP method, but do you think there's any harm in adding these few?

Apr 5, 2012 at 6:17 AM

Just as a quick update, these changes have been checked in.