public log Login(LoginModel model, bool persistCookie = false) { string url2 = "http://localhost:3000/courses/login.json?"; //bool result = false; //string url2 = "http://localhost:3000/courses/login.json"; //bool result = false; string ver = model.UserName.ToString(); var json = new Enlace().EjecutarAccion(url2 + "username="******"&password="******"GET"); var serializer = new JavaScriptSerializer(); log result2 = serializer.Deserialize<log>(json); //if (result2.value) //{ //ViewBag.log = log; //return RedirectToAction("Index", "Home"); // Course result = serializer.Deserialize<Course>(json); // result = true; //} //else // result = false; return result2; }
public ActionResult Login(LoginModel model, string returnUrl) { log result = db.Login(model, persistCookie: model.RememberMe); if (result.role != null) { System.Web.HttpContext.Current.Session["usuario"] = result.role; if (result.role.Equals("admin")) { return RedirectToAction("Index", "Home"); } if (result.role.Equals("student")) { ViewBag.log = result; return RedirectToAction("studentCourse", "student", new { id = result.identification }); } if (result.role.Equals("professor")) { return RedirectToAction("professorCourse", "professor", new { id = result.identification }); } } // Si llegamos a este punto, es que se ha producido un error y volvemos a mostrar el formulario ModelState.AddModelError("", "El nombre de usuario o la contraseña especificados son incorrectos."); return View(model); }