DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Session State....The case of the missing Session scope....

  1. #1
    KraKheD Guest

    Session State....The case of the missing Session scope....


    Our project uses a .Net component loaded in memory, i.e. session state, to
    cache user specific information. The object can be referenced from a web
    page on postbacks and from the business layer when we need it.

    Here's the problem....

    A object in session state CANNOT obtain a reference to another session object.
    There is a timeout event that occurs if the user has been inactive for 30
    minutes. This event IS captured by this component, however, we need to reference
    another piece of data from another object stored in Session state. We have
    a shared function which returns a reference to the object, but everytime
    we run the following code the result is a null reference.

    Dim ctx As HttpContext = HttpContext.Current


    The variable, ctx, is nothing which means we cannot obtain references to
    other session objects.

    Is there a way to do this?
    Any creative ways around it? (No database solutions, .Net code only)

    Thanks in advance.

  2. #2
    Ian Lowe Guest

    Re: Session State....The case of the missing Session scope....

    Hi,

    > A object in session state CANNOT obtain a reference to another session

    object.
    > There is a timeout event that occurs if the user has been inactive for 30
    > minutes. This event IS captured by this component, however, we need to

    reference
    > another piece of data from another object stored in Session state. We have
    > a shared function which returns a reference to the object, but everytime
    > we run the following code the result is a null reference.


    If I understand your problem correctly, your user's session is timing out,
    which prevents access to other objects in the session. I faced a similar
    problem, but was only trying to access a single object in the session
    collection from an ASP.NET code-behind. My solution was to verify that the
    user was still authenticated, and then rebuild the session state.

    If your users are expected to spend more than 30 minutes on a page before
    submitting changes, and rebuilding session state is not an option (if, for
    example, the object's in the session collection are dependant on previous
    activity on the site), you may want to consider one of the following
    options.

    1) Simply increase the session timeout. This is easiest, but may not address
    your problem fully.
    2) Embed the information required to rebuild session state in the page sent
    to the client. You can do this with hidden <input>'s, or with the page's
    ViewState. However, if the information is sensitive, you'll want to use SSL
    or manually encrypt the information. This may also increase the size of your
    pages too much resulting in unacceptable download times.
    3) Redesign the pages so that the object's in session can be called
    statelessly.

    There may be more direct ways to access dead session objects, but I'm
    unaware of any.

    Ian.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center