を投稿Asp.net MVCのフォームは、私は私のContact_Usにこのような形を持っている
@model vidiaweb_com.Models.Contact_US
....
<div id="contactus">
<div class="container">
<form class="form-group col-md-8">
<div id="contactuspost">
<h3 class="txtformat">Contact Us</h3>
<p class="txtformat">
We are here to answer any questions you may have. Reach out to us and we will respond as soon as we can.
</p>
<p class="txtformat">
Even if there is something you have always wanted to experience and can't find it on combadi, let us know and we promise we'll do our best to find it for you and send you there.
</p>
<br />
<div class="form">
@using (Html.BeginForm("Create", "Contact_Us"))
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<div class="form-group">
@Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2 txtformat" })
<div class="col-md-12">
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
</div>
</div>
....
</div>
}
</div>
</div>
</form>
</div>
</div>
....
@Html.Partial("_MainFooter")
を見ると、私はフォームを記入して、提出をクリックすると、これは私のContact_UsController
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "Id,Name,Email,Phone,Message,Date")] Contact_US contact_US)
{
if (ModelState.IsValid)
{
db.Contact_US.Add(contact_US);
db.SaveChanges();
return RedirectToAction("Index","Home");
}
return RedirectToAction("Index", "Home");
}
が、ビューでありますボタンをクリックすると、Contact_Us
コントローラではCreate
アクションが呼び出されません。このようなものは、私のURL
http://localhost:50074/Contact_Us/Index?__RequestVerificationToken=nrlDXOQglmGEzSQMqOqxm8ol4GiKeLffHoQUnLmuwhlIGcSFQfBrQxhZA8EL39nPLmG1FJQK42X284v60l6oepOytsmHLgwDOJYOgfmYnFU1&Name=dg&Email=d%40d.com&Phone=SF&Date=&Message=SFD
であり、それは私のContact_Usインデックスビューに再びリダイレクトします。
私のプロジェクトにはこのような別のフォームがありましたが、正しく動作します。誰が何が問題なのか考えているのですか?ありがとう
これは唯一のフォームですか? (無効なネストされたフォームがあるように見えます)。そして、このビューを生成した 'Index()'メソッドです。 –
はい@StephenMuecke私は私の見解でこの1つのフォームを持っています。あなたのケアのおかげで –
本当ですか?あなたは全体像を投稿できますか? –