Note that there are some explanatory texts on larger screens.

plurals
  1. POAttribute routing with http PUT method constraint
    text
    copied!<p>I'm using the new attribute routing with MVC5 and have gotten http <code>GET</code> and <code>POST</code> method constraints to work by adding the <code>[HttpGet]</code> and <code>[HttpPost]</code> attributes to my action methods. But when I add <code>[HttpPut]</code> I just get a 404 error page. Does anyone know what I need to do to get attribute routing working with http <code>PUT</code>? See code below:</p> <pre><code> [HttpGet] [Route("edit")] public ActionResult Edit() { // this works return View(); } [HttpPost] [Route("insert")] public ActionResult Insert() { // this works return View(); } [HttpPut] [Route("update")] public ActionResult Update() { // this does not work return View(); } </code></pre> <p>I've tried with <code>X-HTTP-Method-Override=PUT</code></p> <pre><code>POST /update HTTP/1.1 Host: localhost:61794 Content-Length: 32 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36 Content-Type: application/x-www-form-urlencoded X-HTTP-Method-Override=PUT&amp;text= </code></pre> <p>And also with a real <code>PUT</code></p> <pre><code>PUT /update HTTP/1.1 Host: localhost:61794 Content-Length: 5 Cache-Control: max-age=0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36 Content-Type: application/x-www-form-urlencoded text= </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload