Take a look at this page: What if the current ASP.NET session is null? . He got a pretty good explanation of the possibilities.
Edit
You would rarely find yourself in a situation where it is not known whether the session object is available and which you want to receive from it. In most cases, including those mentioned in other answers, HttpContext.Current.Session [key] will be null, but not HttpContext.Current.Session.
In most everyday scripts, the Session object will not be empty, and the code in your question will be redundant. Similarly, if you know that the Session object is null ahead of time, you should not even try to access it.
If your application accesses the Session object in an unusual scenario, when it may or may not be null, then your code will be a good way to process it, for example, described in the above question.
source share