As we all know web pages are stateless pages and we need to use session variables in web application to maintain some session over page. Some time we divide our application into multiple layers for example business logic layer,database layer etc. This all layers will be a class library projects.
So when you have your applications divided into the multiple layers at that time you might need to use session variables in the class library projects. For that we are adding System.Web namespace as a reference to a class library project and then we can use session with HttpContext object. That’s works fine if your layers are going to be used in web application projects. But for example if you have service oriented architecture and your services also access your class libraries via non standard protocol i.e. WCF Service hosted on TCP/IP bindings. At that time sessions will not work.
Instead of that you should always use the parameters in method and avoid direct use of session variables. That parameters will passed either from the web application or from the services which is calling the class libraries.
Hope you liked it. Stay tuned for more..