I have an web application that I have inherited and I am trying to update.
When I try to use the application from <i>certain pages </i> (aspx.cs) and when the app tries to set a session variable in a class (.cs file as oposed to a aspx.cs page) I get an object reference not set to an instance of an object exception. This only happens from certain pages.
HttpContext.Current.Session.Contents[ "mySessionVariable" ] = "hello"; // => returns object reference not set to an instance of an object
However if I am using some other pages that use the same .cs class I do not get this exception.
Can someone please explain why trying to create a session variable like this (above) will sometime throw an exception if being called by some pages and not when called by others?
I hope this is not too vague, I am trying to be percise without overloading you with unnecessary details.
I will be glad to explain more if necessary.