MVC Ajax.ActionLink nicht finden POST-Methode
Habe ich eine POST-deklarierte Methode in meinem controller:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UpdateComments(int id, string comments)
{
//...
}
und einen ActionLink in meiner Ansicht:
<%= Ajax.ActionLink("update", "UpdateComments",
new { id = Model.Id, comments = "test" },
new AjaxOptions {
HttpMethod="POST",
OnFailure="alert('fail');",
OnSuccess = "alert('success');"
})%>
Bekomme ich ein "not found" Fehler, wenn er versucht zu route mit dieser Anfrage.
Wenn ich entfernen Sie die POST-Einschränkung aus der UpdateComments Methode im controller, es funktioniert gut.
Was bin ich?
InformationsquelleAutor der Frage fearofawhackplanet | 2010-06-14
Du musst angemeldet sein, um einen Kommentar abzugeben.
Es scheint, dass es nicht die Art, wie ich war, deklarieren meine
OnFailure
undOnSuccess
Rückrufe. Ich denke, es konnte nicht analysiert meineAjaxOptions
Objekts, so war das ignorieren derHttpMethod="POST"
Einstellung.Ich habe es funktioniert durch ändern auf:
InformationsquelleAutor der Antwort fearofawhackplanet
Lerne ich ASP.MVC in diesem moment und ich hatte das Problem mit meinem Ajax.ActionLink, ich habe eine GET-Methode und nicht eine POST-Methode, wie sollte es auch gewesen war. Dann merke ich, dass ich nicht fügen Sie die Skripts Bibliothek Referenz:
Nachdem ich hinzufügen das Skript funktionierte es gut!
InformationsquelleAutor der Antwort Carlos
InformationsquelleAutor der Antwort Vladimir Shmidt
einschließlich versuchen
InformationsquelleAutor der Antwort Bers