2012-06-19

How to access session variables from App_Code folder

You can use the below code to access session values within a class inside a App Code folder

System.Web.SessionState.HttpSessionState session = HttpContext.Current.Session;
session["key"] = "test";

Note: From Visual Studio 2010, App_Code folder will not be available for a web application project by default. But you can still create a new folder named App_Code and it will just work fine.

No comments: