Hi all,
I'm getting some funky behavior with session variables with Razor .cshtml pages. Essentially on some pages I check to see if a Session variable is set, and if not I set it. I keep getting a null object reference.
I believe this is because ultimately Razor is designed for MVC, and I did a little reading about the MVC life cycle and apparently the session object is injected a a different point in the lifecyde then say asp.net webforms. So When I try to use it on my pages it isn't available yet.
So my question would be for simple sites based with Razor (not MVC yet, but moving that way) what would be an effective way to check if a session variable is set (like say "access level") that is checked fairly often. That would be part one of the question.
Part two of the question would be if this is bad practice, what then should I be doing to replace this approach?
Thank you for your input.