MapRouteMVC 5つの路線ポストモデルでは、(私はAntiForgeryTokenを削除...
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" />
}
私は自分のフォームをポストに動作しません。 )、同じ結果をテストした。
HTTPエラー404.0から
ContactFormアクションがあるコントローラの名前は何ですか? – MartinM
コントローラ:SiteHomeControllerアクション:ContactForm。メソッドは動作しますが、投稿を表示しようとすると404が表示されます。 – Actionsee
どのようにフォームを投稿していますか?あなたは偽造防止のトークンのクライアント側を扱っていますか? – MartinM