httphandler session scope

T

Ty

Hi, All-

I have a custom httphandler that outputs an image to the browser based
upon some user input. I'd like to be able to store information about
that image in session and have them accessible to all aspx pages in my
project. Session state seems to be working normally in my handler,
however, the session variables are not accessible anywhere outside the
handler itself. Any ideas?


Thanks in advance
Ty
 
T

Ty

Hi, Peter-

First off, thanks for responding. As to your question, yes, and
session is working perfectly within the handler itself. I have gotten
a bit further with this problem...in my global.asax file's
Session_Start event I have the following:

HttpContext ctx = HttpContext.Current;
MapEngineHttpHandler.DTMapEngineHandler mapHandler = new
MapEngineHttpHandler.DTMapEngineHandler();
mapHandler.ProcessRequest(ctx);
Session["NewSessionVariable"]= ctx.Session["SessionID"];

So I am able to retrieve the SessionID session variable that I created
in the Handler, but I am not able to retrieve the value of
Session["NewSessionVariable"] on any other pages. SessionState mode is
currently InProc....

Thanks
Ty
 
T

Ty

I should probably also let you know that my goal here is to somehow
wire up the HttpHandler such that session variables that are modified
in the handler during run-time are also available to all other pages
during run-time, not just when session starts...
 
T

tdavisjr

I'm not sure why you would have to implement this interface for a
HttpHandler, since the System.Web.UI.Page object don't even implement this
interface, yet you can access session state from aspx pages. I know you
have to implement this if doing a custom module if you want to access
session state.
 
T

Ty

Perhaps I'm not being clear....I definitely need to access session from
within my custom handler, which is why I implemented the
irequiresessionstate interface. I have an object in my handler, which
is unique to the session, that I need to access in higher-level pages
such as asp and aspx pages. Users should not be able to share this
object as it changes based on user input, so we store it in session in
the handler itself. Now say I need access to that session
variable(which holds the object) elsewhere in my web app...how would
one go about doing this?
 
T

Ty

After some more testing I've found that getting at the session
variables created in the handler is obviously very easy from aspx
code-behinds, but my test scenario involves a few classic asp pages.
This is where my problem lies as asp and asp.net are not running under
the same process & won't be able to share session data. Thanks to all
who replied.
 
G

Guest

Ty,
In ASP.NET 2.0, your Session doesn't become live until an object has
actually been added to Session State. So most likely your Session_Start
handler isn't even being fired. Move the code out of the Session_Start event
handler.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




Ty said:
Hi, Peter-

First off, thanks for responding. As to your question, yes, and
session is working perfectly within the handler itself. I have gotten
a bit further with this problem...in my global.asax file's
Session_Start event I have the following:

HttpContext ctx = HttpContext.Current;
MapEngineHttpHandler.DTMapEngineHandler mapHandler = new
MapEngineHttpHandler.DTMapEngineHandler();
mapHandler.ProcessRequest(ctx);
Session["NewSessionVariable"]= ctx.Session["SessionID"];

So I am able to retrieve the SessionID session variable that I created
in the Handler, but I am not able to retrieve the value of
Session["NewSessionVariable"] on any other pages. SessionState mode is
currently InProc....

Thanks
Ty
Your handler implements IRequiresSessionState?


--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top