即使使用MVCConrib的ModelStateToTempData,我在重定向後仍未顯示驗證消息時出現問題。我是否忽略了一些基本的東西重定向後不顯示驗證消息(使用ModelStateToTempData屬性)
[ModelStateToTempData]
public class AccountController : BaseController
{
public ActionResult LogOn(string email, string password, string returnUrl)
{
if (!ValidateLogOn(email, password))
{
return RedirectToAction("Index", "AnotherController");
}
//other stuff
}
private bool ValidateLogOn(string email, string password)
{
if (!_userTask.ValidateUser(email, password))
{
ModelState.AddModelError("message", "The email or password provided is incorrect.");
}
return ModelState.IsValid;
}
}
查看:
<li>
<label for="email">E-mail</label>
<%= Html.TextBox("email")%>
<%= Html.ValidationMessage("message") %>
</li>
我需要我來試試 – Dan 2009-07-14 21:28:28
該訣竅? - 現在,很明顯你說。 – Dan 2009-07-14 21:30:40