1
I am trying to return a page according to the user profile registered in the bank. If his profile is "Admin" returns another page. I try with the Administrator profile and it works, already of another user, I changed his profile in the bank and does not return the right profile.
Can someone help me ? My code is this:
 public ActionResult LogOn(FormCollection f, string returnUrl)
        {
            Conta user = new Conta();
            ContaModels atrrConta = new ContaModels();
            atrrConta = user.RetornaUser(f["login"]);
            if (user.AutenticaUser(atrrConta, f["senha"]))
            {
                //Rotina para autenticar usuario
                if (returnUrl == "" || returnUrl == null)
                {
                    returnUrl = "../CalendarioAlertaSMS";
                }
                System.Web.Security.FormsAuthentication.SetAuthCookie(f["login"], false);
                Session["PERFIL"] = atrrConta.Ide_Perfil;
                if (Session["PERFIL"].ToString() == "ADMIN")
                {
                    returnUrl = "../PainelAdm";
                }
                return Redirect(returnUrl);
            }
            else {
                ViewBag.Message = "Login ou senha inválidos.";
                return View(); 
            }
        }
This method does not appear to me here not @Rafael Cabral.
– AndreeH
returns any errors? if it still doesn’t workVoce can use 'Return View("nameAction")'
– Rafael Cabral
It’s just that I’m starting in MVC now, just manjo de webforms. rs
– AndreeH
rs, an example for you to better understand:
return RedirectToAction("Details");ai it will return to the actionresult Details control– Rafael Cabral
I tried, only he doesn’t recognize Redirecttoaction. Need to import some library ?
– AndreeH