2

MVCConrib の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>  
4

3 に答える 3

0

ビューに検証メッセージを確実に表示していますか?

于 2009-07-14T20:47:41.107 に答える