我一定是犯了一个小错误,因为这个设置“应该”工作,但是当点击提交时,我的控制器甚至没有在调试中命中。
HTML
@using (Html.BeginForm("sendMail", "LakerLegends", FormMethod.Post))
{
<table>
<tr>
<th class="col-xs-9">
Name
<br />
<input name="name" type="text" required />
<br />
Email
<br />
<input name="email" type="text" required />
<br />
Category
<br />
<select name="category" style="font-size: 18px; padding: 0px" required>
<option value="0">General</option>
<option value="1">Teams</option>
<option value="2">Events</option>
<option value="3">Website</option>
<option value="4">Internal</option>
</select>
<br />
Details
<br />
<textarea name="details" cols="25" required></textarea>
<br />
<input type="submit" value="Save" class="form-group" />
<br />
<i>An officer will contact you within the next 24 hours.</i>
</th>
<th colspan="1">
<img src="/Content/img/contactIcon.png" style="opacity:.7" />
</th>
</tr>
</table>
}
控制器
[HttpPost]
public ActionResult sendMail(string name, string email, string category, string details)
{
try
{
return RedirectToAction("Index");
}
catch (Exception)
{
// Some code
}
return RedirectToAction("Index");
}
单击提交似乎只是重新加载页面。