Convert a Session to Boolean - asp.net mvc?

3

I have in my system a Session that stores an information "S" or "N"

Session["Administrador"] = retorno.ADMINISTRADOR;

In the layout I want to make the conversion of it to boolean

@{
    bool administrador = bool.Parse(Session["Administrador"].ToString());
}
    
asked by anonymous 09.11.2016 / 14:29

1 answer

3

Try this:

@{
    bool administrador = Session["Administrador"].ToString() == "S";
}

or

@{
    bool administrador = Session["Administrador"].Equals("S");
}
    
09.11.2016 / 14:31