MapRoute
routes.MapRoute(
name: "ContactForm",
url: "contact-form.html",
defaults: new { controller = "SiteHome", action = "ContactForm" },
namespaces: new[] { "Presentation.Controllers" }
);
Action Method
[AllowAnonymous]
[AcceptVerbs(HttpVerbs.Post)]
[ValidateAntiForgeryToken]
public ActionResult ContactForm(ContactForm postForm)
{
}
Contact Form 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" />
}
When i post my form.. I removed AntiForgeryToken() and tested same result.
HTTP Error 404.0 - Not Found