Keeping objects between requests within the same session

D

Don

I have an ASP.NET program that references a VB.NET DLL. I had originally
planned for my DLL to put things in the HttpContext.Current collection so
that the ASP.NET can access them throughout an entire session (according to
a tip I saw on a website somewhere), but it turns out that it only lasts for
the current page request. If another page is requested, the contents of
HttpContext.Current are cleared. Except for the lack of proper scope,
HttpContext.Current gives me the functionality that I need.

Is there another class I can throw this stuff into, similar to the way
HttpContext.Current works, that will let the objects last for the entire
session and not just the current request? In ASP.NET there's a Session
class which has the right scope, but I don't know how -- or even if it's
possible -- to access that class from by VB.NET DLL.

- Don
 
D

Don

Don said:
Is there another class I can throw this stuff into, similar to the way
HttpContext.Current works, that will let the objects last for the entire
session and not just the current request? In ASP.NET there's a Session
class which has the right scope, but I don't know how -- or even if it's
possible -- to access that class from by VB.NET DLL.

I forgot to mention that I need to be able to recreate this class in a
Windows app. I mean to do this so as to make it seem like a person running
a Windows app is like one session at a website. Again, HttpContext.Current
worked perfectly for everything...except that it just had the wrong scope
for my ASP.NET application.

- Don
 
T

Teemu Keiski

Hi,

HttpContext.Current.Session

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

I have an ASP.NET program that references a VB.NET DLL. I had originally
planned for my DLL to put things in the HttpContext.Current collection so
that the ASP.NET can access them throughout an entire session (according to
a tip I saw on a website somewhere), but it turns out that it only lasts for
the current page request. If another page is requested, the contents of
HttpContext.Current are cleared. Except for the lack of proper scope,
HttpContext.Current gives me the functionality that I need.

Is there another class I can throw this stuff into, similar to the way
HttpContext.Current works, that will let the objects last for the entire
session and not just the current request? In ASP.NET there's a Session
class which has the right scope, but I don't know how -- or even if it's
possible -- to access that class from by VB.NET DLL.

- Don
 
D

Don

I tried using that, but when working with my Windows App accessing the DLL,
the HttpContext.Current.Session resolves to Nothing. Is there some way to
initialize it? When I had my code working with just HttpContext.Current, I
needed to put the following line at the start of my Windows app:

HttpContext.Current = New HttpContext(Nothing, Nothing)

to initialize it, so to speak (I imagine this is explicitly doing what, in a
way, the environment is doing for my ASP.NET program). I don't know what to
do to initialize HttpContext.Current.Session at the start of my Windows app,
though.

- Don
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top