More in this section

Forums / Developing with Sitefinity / Getting HttpContext with CacheSubstitutionUserControl

Getting HttpContext with CacheSubstitutionUserControl

2 posts, 0 answered
  1. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    20 Mar 2009
    Link to this post
    I am using CacheSubstitutionUserControl... I do not have access to HttpContext.Current.Session...

    Does anyone know how to resolve this i need to access some session variables.

    Duncan
  2. Bob
    Bob avatar
    330 posts
    Registered:
    30 Dec 2016
    23 Mar 2009
    Link to this post
    Hello Duncan,

    Unfortunately you cannot access session variables when substituting.

    I already answered this in the comments of the blog post, but here is the answer again:

    Session state is not available, but authentication information is available as the request is authenticated prior to output cache resolution. In fact the samples above work exclusively with authentication information. Query string is also available.

    In a future version we may provide the option to force loading session state as well, but for the time being you have to work around it.

    There are several possible ways to avoid using session state. You can use database to store temporary user info, you can retrieve the session id form the cookies and use it as key to store user info in the Cache instead of the Session object, you could create your own session handling or use query string instead.

    If you use the cache object to store session data, don’t forget to set appropriate expiration.

    Greetings,
    Bob
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
2 posts, 0 answered