How to Get Session Value in Class File?
Get session value in C#Answer: When you try to access sessions in class file from the App_Code directory the property will not be available to you unless your class derives from the Page Class. You can use threads HttpContext to access the session value in class.
string _userVal = Convert.ToString(HttpContext.Current.Session["user"]);
[post_ad]ASP.Net web pages contain a default reference to the System.Web namespace (which contains the HttpContext class), you can reference the members of HttpContext on an .aspx page without the fully qualified class reference to HttpContext.
I hope you will enjoy the interview tips while learning asp.net session. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome. Also If you like this article, don't forget to share this article with your friends and colleagues.