How to retrieve parameter from a Controller

0

After the user logs in, two parameters are passed to Controller Home :

case SignInStatus.Success:
{
   //recupera as informações do usuario que corresponda ao usuario e password
   var user = await UserManager.FindAsync(model.Usuário, model.Password);

   //redireciona o login para o index o controller home
   return RedirectToAction("Index", "Home", new { 
           cod_cli = user.cod_cli, 
           razao_social = user.razao_social 
   });
}   

However, on another page I have a button that also redirects to Action Index of Controller Home :

@Html.ActionLink("OneeWeb", "Index", "Home", new { 
      area = "", 
      cod_cli = "parametro1", 
      razao_social = "parametro2" 
}, new { @class = "navbar-brand" })

My question is, how do I recover these parameters? they do not change, they are fixed for each user.

In this case, would it be good to store these parameters in Cookie ?

    
asked by anonymous 11.07.2017 / 22:13

1 answer

0

I was able to solve the problem by starting to work with Sessions .

For more information: Which the difference between Sessions and Cookies

After user login, the object with the user data is obtained:

case SignInStatus.Success:
                {
                    //recupera as informações do usuario que corresponda ao usuario e password
                    var user = await UserManager.FindAsync(model.Usuário, model.Password);                       
                    Session["cod_cli"] = user.cod_cli;
                    Session["razao_social"] = user.razao_social;

                    //redireciona o login para a pagina que o usuario estava.
                    //return RedirectToLocal(returnUrl);
                    //redireciona o login para o index o controller home
                    return RedirectToAction("Index", "Home", new { cod_cli = Session["cod_cli"], razao_social = Session["razao_social"] });
                }  

And then, I use two Session to "save" the data you need, and then use it on other pages ..

    
12.07.2017 / 01:18