0
routes.MapRoute(
name: "ContactForm",
url: "contact-form.html",
defaults: new { controller = "SiteHome", action = "ContactForm" },
namespaces: new[] { "Presentation.Controllers" }
);
操作方法
[AllowAnonymous]
[AcceptVerbs(HttpVerbs.Post)]
[ValidateAntiForgeryToken]
public ActionResult ContactForm(ContactForm postForm)
{
}
聯繫表格代碼
@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" />
}
當我發表我的形式..我刪除AntiForgeryToken( )並測試了相同的結果。
HTTP錯誤404.0 - 找不到
ContactForm操作所在控制器的名稱是什麼? – MartinM
控制器:SiteHomeController操作:ContactForm。獲取方法的作品,但當我嘗試顯示404後的帖子。 – Actionsee
你是如何發佈表單?你是否正在呼叫處理防僞令牌客戶端? – MartinM