I am not able to access the session or application object in my .cs file. I am using C# & asp.net on .net 2.0.Its not showing Session or Application object in the editor drop down list too.
How Can I Access The Session Or Application Object In My .cs File. I Am Using C# & Asp.net 2.0?
November 23rd, 2009 by CTO WebOjO.com website designers Lahore Pakistan Leave a reply »
Advertisement
Is you CS file part of the web application or is it in another class library?
If it is in another class library you should reference the System.Web dll first then in your code you will be able to access the Session through:
System. Web. HttpContext. Current. Session["key"]
If you CS file is in your web application you just access the object
Session["key"]
In both cases you’ll have to cast to your type from object.
Hope this helps.