Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6176767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:09:33+00:00 2026-05-24T00:09:33+00:00

First a brief background. I am using .NET output caching and substitution controls to

  • 0

First a brief background. I am using .NET output caching and substitution controls to keep a few bits updated on each page refresh. The static methods that the substitution controls use require access to the Session object. Unfortunately, the HttpContext session is null in those methods.

I’m not going to rewrite my app to use a different store than the Session. Session is perfect for everything I need except this one aspect.

Can I manually create or populate a session object or otherwise get at its data by some sort of black magic wizardry? The session cookie is still being set from the client to the server. The info has got to be there somewhere. How do I get at it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:09:35+00:00Added an answer on May 24, 2026 at 12:09 am

    I’m not convinced this is a “good” way to go…but you can very dodgily store a reference to the Session in a shared/static variable and access it then.

    Public Class SessionHelper
    
        Public Shared TheSession As HttpSessionState
    
    End Class
    

    In your Session Start event (haven’t figured out the best place to put it yet as the session isn’t available in Application start as far as I am aware)

    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
    
        ' Store a reference...only do this once etc etc
        If SessionHelper.TheSession Is Nothing Then
            SessionHelper.TheSession = HttpContext.Current.Session
        End If
    
    End Sub
    

    Then in your code you can just reference the helper

    Dim someVariable as String = SessionHelper.TheSession.Item("ItemName")
    

    A few things I’m not sure about this method:

    • not sure if the session object is now not thread safe
    • it doesn’t seem quite right
    • this example is extremely simple…

    Edit
    I verified this worked for me by adding something to the cache and seeing if the session was available in the Cache Remove Callback which Http.Context.Current is not available in.

    Edit 2
    Here’s a screenshot of it correctly returning the value. So it must be working to some degree, but the fact that the SessionId is not set is kind of worrying…I know I’ve used this technique before to access the Cache object but the cache is the cache, where as the session does need something to identify each session…Here you go anyway:
    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.