locked
Httphandler and session state issues RRS feed

  • Question

  • User798525303 posted

    Hi,

    I have made a simple httphandler for processing image requests. This handler needs to have access to the session state variable. My handler implements IRequiresSessionState Interface and ProcessRequest is called on every image request. The issue is that for each request a new session is initialized and passed to the handler. This is obvious from records inserted in sql server session database. To demonstrate the issue I have modified the handler to simply write to response output the session state members. Please follow the link below and notice that every time you refresh the page a new SessionID is generated. This does not happen on any other portion on my web application. Session is maintained appropriately on all other aspx page requests.

    This site is hosted in a web farm on hosting provider [A] where the issue appears.
    http://www.iems-demo.com/userdata/estudents/common/images/901.png
    This is the same site hosted on hosting provider [B], on a shared hosting package where session works as expected.
    http://iems-demo.com.previewdns.com/userdata/estudents/common/images/901.png

    I really need some help here as any assistance i asked from hosting provider [A] to resolve this issue pointed me in the wrong direction (i think). Is this a known issue on web farms, does it have to do with my configuration?

    Any help would really be appreciated.

    Friday, January 29, 2010 6:50 PM

Answers

  • User798525303 posted

    amanbhullar, issue resolved.

    The reason a new session was generated on every request in my handler was that they used a picture caching server for images and all requests for images passed through the caching server and not web server.

    Thanks for taking the time to respond.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Saturday, January 30, 2010 6:55 AM

All replies

  • User357473681 posted

     InProc session mode will work fine on Shared Hosting, but in case for Farm hosting you need to implement either StateServer or SQLServer session mode

    Saturday, January 30, 2010 12:39 AM
  • User798525303 posted

    amanbhullar, thanks for replying.

    Sorry, but maybe i did not make myself clear.
    I do implement Sql Server session mode. As i said when the above link is refreshed i can see a new record inserted in the ASPStateTempSessions table in my Session DB with a new SessionId.

    In my web app session works just fine and is stored in database as expected.
    The problem appears only in my Http handler. My http handler implements IRequiresSessionState and indeed Context.SessionState is not null. In case of the web farm it is a completly new session with a new session id in every call to ProcessRequest.

    The urls above indicate this issue as i have modified my my handler to write to the response the SessionState members. You will see in the web farm that a new SessionId is written to the output on every request and that for that Session no keys exist.

    Saturday, January 30, 2010 4:43 AM
  • User798525303 posted

    amanbhullar, issue resolved.

    The reason a new session was generated on every request in my handler was that they used a picture caching server for images and all requests for images passed through the caching server and not web server.

    Thanks for taking the time to respond.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Saturday, January 30, 2010 6:55 AM