httphandler session scope

Discussion in 'ASP .Net' started by Ty, Jul 27, 2006.

  1. Ty

    Ty Guest

    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
    Ty, Jul 27, 2006
    #1
    1. Advertising

  2. Your handler implements IRequiresSessionState?


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




    "Ty" wrote:

    > 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
    >
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Jul 27, 2006
    #2
    1. Advertising

  3. Ty

    Ty Guest

    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

    Peter wrote:
    > Your handler implements IRequiresSessionState?
    >
    >
    > --
    > Co-founder, Eggheadcafe.com developer portal:
    > http://www.eggheadcafe.com
    > UnBlog:
    > http://petesbloggerama.blogspot.com
    >
    >
    >
    >
    > "Ty" wrote:
    >
    > > 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
    > >
    > >
    Ty, Jul 27, 2006
    #3
  4. Ty

    Ty Guest

    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...
    Ty, Jul 27, 2006
    #4
  5. Ty

    tdavisjr Guest

    "Peter Bromberg [C# MVP]" <> wrote in message
    news:...

    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.


    > Your handler implements IRequiresSessionState?
    >
    >
    > --
    > Co-founder, Eggheadcafe.com developer portal:
    > http://www.eggheadcafe.com
    > UnBlog:
    > http://petesbloggerama.blogspot.com
    >
    >
    >
    >
    > "Ty" wrote:
    >
    >> 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
    >>
    >>
    tdavisjr, Jul 27, 2006
    #5
  6. Ty

    Ty Guest

    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?

    tdavisjr wrote:
    > "Peter Bromberg [C# MVP]" <> wrote in message
    > news:...
    >
    > 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.
    >
    >
    > > Your handler implements IRequiresSessionState?
    > >
    > >
    > > --
    > > Co-founder, Eggheadcafe.com developer portal:
    > > http://www.eggheadcafe.com
    > > UnBlog:
    > > http://petesbloggerama.blogspot.com
    > >
    > >
    > >
    > >
    > > "Ty" wrote:
    > >
    > >> 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
    > >>
    > >>
    Ty, Jul 27, 2006
    #6
  7. Ty

    Ty Guest

    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.

    Ty wrote:
    > 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?
    >
    > tdavisjr wrote:
    > > "Peter Bromberg [C# MVP]" <> wrote in message
    > > news:...
    > >
    > > 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.
    > >
    > >
    > > > Your handler implements IRequiresSessionState?
    > > >
    > > >
    > > > --
    > > > Co-founder, Eggheadcafe.com developer portal:
    > > > http://www.eggheadcafe.com
    > > > UnBlog:
    > > > http://petesbloggerama.blogspot.com
    > > >
    > > >
    > > >
    > > >
    > > > "Ty" wrote:
    > > >
    > > >> 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
    > > >>
    > > >>
    Ty, Jul 27, 2006
    #7
  8. 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" wrote:

    > 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
    >
    > Peter wrote:
    > > Your handler implements IRequiresSessionState?
    > >
    > >
    > > --
    > > Co-founder, Eggheadcafe.com developer portal:
    > > http://www.eggheadcafe.com
    > > UnBlog:
    > > http://petesbloggerama.blogspot.com
    > >
    > >
    > >
    > >
    > > "Ty" wrote:
    > >
    > > > 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
    > > >
    > > >

    >
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Jul 27, 2006
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nicolas Beunier

    HttpHandler and Session Issue

    Nicolas Beunier, May 28, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    764
    Nicolas Beunier
    May 31, 2004
  2. Igor K
    Replies:
    4
    Views:
    631
    Matt Berther
    Sep 24, 2004
  3. Igor K

    httphandler and session state

    Igor K, Sep 24, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    5,355
    Igor Kramaric
    Sep 26, 2004
  4. Jeremy Lew

    null Session object in HttpHandler

    Jeremy Lew, Sep 25, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    659
    Igor K
    Oct 11, 2004
  5. Michael Schwarz

    cookieless Session and httpHandler configuration

    Michael Schwarz, Apr 4, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    2,208
    Steven Cheng[MSFT]
    Apr 5, 2006
Loading...

Share This Page