Can we use session variables in a class ?

 Posted by Chvrsri on 2/24/2012 | Category: C# Interview questions | Views: 3142 | Points: 40
Answer:

Yes we can use session variables in class. This can be done using this way

First of all we need to import the name space

Use HttpContext.Current.Session

In C#.Net

HttpContext.Current.Session["Value1"] = "1";


In VB.Net

HttpContext.Current.Session("Value1") = "1"  


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response