我有形式這樣在我CONTACT_US視圖Asp.net MVC形式發佈
@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
行動。這樣的事情在我的網址
http://localhost:50074/Contact_Us/Index?__RequestVerificationToken=nrlDXOQglmGEzSQMqOqxm8ol4GiKeLffHoQUnLmuwhlIGcSFQfBrQxhZA8EL39nPLmG1FJQK42X284v60l6oepOytsmHLgwDOJYOgfmYnFU1&Name=dg&Email=d%40d.com&Phone=SF&Date=&Message=SFD
並再次將其重定向到我CONTACT_US索引視圖。
我有另一種形式在我的項目是這樣,但一個正常工作。有沒有人有任何想法可能會是什麼問題?謝謝
的是,在您的視圖的唯一形式? (它看起來像你可能有嵌套的表單是無效的)。它是產生這個視圖的'Index()'方法。 –
是@StephenMuecke在我看來,我只有這一種形式。感謝您的關心 –
你確定嗎?你能發佈整個視圖嗎? –