MapRouteMVC 5 Routen Post Modell funktioniert nicht
routes.MapRoute(
name: "ContactForm",
url: "contact-form.html",
defaults: new { controller = "SiteHome", action = "ContactForm" },
namespaces: new[] { "Presentation.Controllers" }
);
Aktion Methode
[AllowAnonymous]
[AcceptVerbs(HttpVerbs.Post)]
[ValidateAntiForgeryToken]
public ActionResult ContactForm(ContactForm postForm)
{
}
Kontaktformular Codes
@using (Html.BeginForm("IletisimForm", "SiteAnasayfa", FormMethod.Post, htmlAttributes: new { @class = "" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.TextBoxFor(model => model.Fullname, new { @class = "w-input easing" })
@Html.ValidationMessageFor(model => model.Fullname, "", new { @class = "text-danger text-bold" })
@Html.TextBoxFor(model => model.Telephone, new { @class = "w-input easing")
@Html.ValidationMessageFor(model => model.Telephone, "", new { @class = "text-danger text-bold" })
@Html.TextBoxFor(model => model.Email, new { @class = "w-input easing")
@Html.ValidationMessageFor(model => model.Email, "", new { @class = "text-danger text-bold" })
@Html.TextAreaFor(model => model.Message, new { @class = "w-input easing" })
@Html.ValidationMessageFor(model => model.Message, "", new { @class = "text-danger text-bold" })
<input type="submit" class="fr w-button easing" value="Send" />
}
Wenn ich meine Form schreiben .. Ich AntiForgeryToken entfernt () und das gleiche Ergebnis getestet.
HTTP-Fehler 404.0 - Nicht gefunden
Wie lautet der Name des Controllers, in dem sich die ContactForm-Aktion befindet? – MartinM
Controller: SiteHomeController Aktion: Kontaktformular. Get Methode funktioniert, aber wenn ich versuche, Post zeigt 404. – Actionsee
Wie posten Sie das Formular? Rufen Sie den Umgang mit der Client-Seite für den Antiforg-Token an? – MartinM