What is the best way to check for the existence of a session variable in ASP.NET C#?
I like to use String.IsNullOrEmpty() works for strings and wonder
String.IsNullOrEmpty()
That is pretty much how you do it. However, there is a shorter syntax you can use.
sSession = (string)Session["variable"] ?? "set this";
This is saying if the session variables is null, set sSession to "set this"