title: How to handle unsupported HTTP methods on actions in ASP.NET MVC5?
body: <p>How do I handle requests to actions that exist, but don't support the http method in the request?</p>
  
  <p>For example, I have the following action:</p>
  
  <pre><code>[HttpGet]
  [Route("~/")]
  [Route("ServiceVisits")]
  public ActionResult Index()
  {
      return View();
  }
  </code></pre>
  
  <p>If a <code>GET</code> request comes to <code>http://localhost:59949/</code> or <code>http://localhost:59949/ServiceVisits</code> then we get the page back, but if a <code>POST</code> request comes, then I get an exception in my <code>Application_Error</code> method in <code>Global.asax.cs</code> that I have to deal with.</p>
  
  <p>Requests that come to non-existent actions will return a <code>404</code> page, because I have the following route:</p>
  
  <pre><code>routes.MapRoute(
      "PageNotFound",
      "{*.*}",
      new {controller = "Error", action = "NotFound"}
  );
  </code></pre>
  
  <p>I'm using Attribute Routing and the above convention is my only one for handling 404's.</p>
  
  <p>I want to log only serious system errors in <code>Application_Error</code> and not <code>No matching action was found on controller</code> exceptions. Thank you!</p>