Controller does not pass route value to View ASP.NET MVC

Asked

Viewed 234 times

1

Based on my previous question: Problem with page return according to C profile# When accessing the system with another user with the "ADMIN" Profile, the controller’s return does not fall into the view and does not call the route of the page that should return. Already accessing with the "System Administrator" works. What might be going on ?

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(); 
            }
        }
  • You have two profiles, "Admin" and "System Administrator", that’s right?

  • @Gypsy Morrison Mendez I have an admin user and another normal one, only with the administrator profile. In the case is equal, only changes the user name.

  • You can put here in your question the updated code?

  • I had opened another forum where I posted it. But I will put again, I .. :)

  • Pronto Cigano ..

  • SetAuthCookie should not be the first instruction within the if?

  • Oh type, when I access with the admin user who has the admin profile works well, it returns the right page that in the case is this ".. /Paineladm". Then I changed the profile of a user and put him as admin, with this was to return this page too and does not return. I put a breakpoint in the view and when access as administrator it falls in it, but then when access with this user does not fall in it ..

  • I tried passing the Setauthcookie first but it still didn’t work ..

  • Dude, this new user you’re testing the information that comes from: atrrConta.Ide_Perfil; is ADMIN in high box? for if it is not going at all.

  • It’s high cashier yes @Ivanteles. I got it man. Thank you.

  • The problem was a Role in a "hidden" location that was allowing access to the page only for Admin user, not users that contained profile "Admin".

Show 6 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.