ASP.NET MVC UpdateModel throws exception: "Model could not be updated"

Viewed 7161

Im trying to update a simple model in MVC,but its not working,it throws an exception saying that the Model could not be updated:

      [HttpPost]
        public ActionResult SignIn([Bind(Exclude="TxtEmail")]Usuarios usuario,FormCollection fc)
        {
            try
            {
                UsuariosModel userModel = new UsuariosModel(usuario);
                userModel.Usuarios.TxtEmail = "test@test.com";

                UpdateModel(userModel);

                if (ModelState.IsValid)
                {
                 [...]
                }
                [...]
        }

This is the model:

[Required(ErrorMessage="**O email é requerido")]
[RegularExpression("^[a-z0-9_\\+-]+(\\.[a-z0-9_\\+-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*\\.([a-z]{2,4})$",ErrorMessage="**Email Inválido")]
public string TxtEmail
{
    get { return this.txt_email; }
    set { this.txt_email = value; }
}

How can i use this method "UpdateModel"?

3 Answers
Related