public ActionResult Login(string Nome, string Senha, string returnUrl) { ViewBag.ReturnUrl = returnUrl; UsuarioRepository objrep = new UsuarioRepository(); var query = objrep.BuscarNomeSenha(Nome, Senha); if (ModelState.IsValid) { if (query != null) { Session["Id"] = query.id.ToString(); Session["Nome"] = query.Nome.ToString(); return(Redirect("/Administrativo/HomeAdm")); } else { ViewBag.Erro = "Usuario Senha Incorreta"; return(RedirectToAction("Login")); } } return(View()); }