473,399 Members | 3,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Access Session State From Class File in App_Code

How does one access session state data from a (custom) class file in
app_code? this.Session["MySessionData"] doesn't work from within the
class file!

Jun 25 '07 #1
2 5411
Of course it won't work, the reason is Session is actually a easy reference
thanks to the System.Web.UI.Page or Controls. You have to reference the
current context anywhere else such as:

HttpContext.Session
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Joey" <jo*********@topscene.comwrote in message
news:11**********************@o61g2000hsh.googlegr oups.com...
How does one access session state data from a (custom) class file in
app_code? this.Session["MySessionData"] doesn't work from within the
class file!

Jun 25 '07 #2
On Jun 25, 3:27 pm, "Mark Fitzpatrick" <markf...@fitzme.comwrote:
Of course it won't work, the reason is Session is actually a easy reference
thanks to the System.Web.UI.Page or Controls. You have to reference the
current context anywhere else such as:

HttpContext.Session

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Joey" <joey.pow...@topscene.comwrote in message

news:11**********************@o61g2000hsh.googlegr oups.com...
How does one access session state data from a (custom) class file in
app_code? this.Session["MySessionData"] doesn't work from within the
class file!- Hide quoted text -

- Show quoted text -
Actually it's HttpContext.Current.Session, but you solved the problem
for me. Thanks.

Jun 25 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: Patrick | last post by:
I have the following code, which regardless which works fine and logs to the EventViewer regardless of whether <processModel/> section of machine.config is set to username="SYSTEM" or "machine" ...
10
by: Ronnie | last post by:
I've created a simple web application using VS2005 Beta 2. Basically, I've added a Web Form and a Global.asax file. In my Global.asax, I create a method like: public static void TestGlobal()...
9
by: charliewest | last post by:
Hello - I have images saved in my SQL SERVER 2000 database. Using ASP.NET (C#) is there any way to temporarily save an image to a session object, and after running some other operations, later...
2
by: Daflookie | last post by:
For one reason or another I am unable to access Session contents in my asp.net application via the global.asax's Application_Error event. I can pull this exact code snippet below out of...
1
by: Mike | last post by:
What is the effect of deploying asp.net 2.0 and the effect of session state to the production application? What happens when you xCopy any modified or new .vb or .cs class file from the...
1
by: Mike | last post by:
When running a 24*7 website, we need to keep the our asp.net 2.0 web applications from restarting as much as possible. Especially during any deployments of aspx, aspx.vb files and possible .vb...
2
by: Ross Culver | last post by:
Ok, how do I fix this c$#^? I get this whenever I attempt to run the ASPNet Configuration from within my solution. The stack references the public key token as not being marked as...
0
by: Ross Culver | last post by:
I've gone round and round on this same issue for weeks unable to find any solution referenced on the Internet or in any forum. I've changed the session management from InProc to SQLServer to...
4
by: Cirene | last post by:
In my web.config I added <pages enableSessionState="true">. In each of my pages I also added EnableSessionState="True" to the Page declaration. (I didn't think this was necessary, but...) ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.