Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/04/2016, 11:36
Paty_RR
 
Fecha de Ingreso: enero-2013
Mensajes: 176
Antigüedad: 11 años, 4 meses
Puntos: 2
Pregunta FormMethod.Post didn´t work with not default action. Razor and MVC 4

I´m new in MVC with Razor... I´m trying to do a login page, so i have this code in my cshtml:

Código ASP:
Ver original
  1. @using (Html.BeginForm("LogOn", "Login", FormMethod.Post))
  2. {
  3.     @Html.LabelFor(m => m.usuario)
  4.     @Html.TextBoxFor(m => m.usuario)
  5.  
  6.     @Html.LabelFor(m => m.password)
  7.     @Html.PasswordFor(m => m.password)
  8.  
  9.     @Html.LabelFor(m => m.rememberMe)
  10.     @Html.CheckBoxFor(m => m.rememberMe)
  11.  
  12.     <input type="submit" value="Iniciar sesión" />                  
  13. }


In the controller i have this:

Código ASP:
Ver original
  1. public class LoginController : Controller
  2. {      
  3.     public ActionResult Login()
  4.     {
  5.         return View();
  6.     }
  7.  
  8.     [HttpPost]
  9.     public ActionResult LogOn(Login lg)
  10.     {
  11.         if(//valido mi usuario)
  12.         {
  13.             return RedirectToAction("MyContent", "MyContent");
  14.         }
  15.  
  16.         return View("Login");
  17.     }
  18.  }

But it never called the action "LogOn" it only called the action default "Login" and i don´t know which is the error...

Pleas help me!!!

Thanks!
__________________
Define tus intereses, se curioso, investiga, comete errores, aprende, practica, mejora, enseña y vuelve a comenzar....