Attributweiterleitung mit Einschränkung der http-PUT-Methode
Ich benutze das neue Attribut Routing mit MVC5 und habe http bekommenGET
undPOST
Methode Einschränkungen zu arbeiten, indem Sie die[HttpGet]
und[HttpPost]
Attribute zu meinen Aktionsmethoden. Aber wenn ich hinzufüge[HttpPut]
Ich erhalte gerade eine 404-Fehlerseite. Weiß jemand, was ich tun muss, damit das Attribut-Routing mit http funktioniert?PUT
? Siehe Code unten:
[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();
}
Ich habe es mit versuchtX-HTTP-Method-Override=PUT
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&text=
Und auch mit einem echtenPUT
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=