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 8941757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:22:30+00:00 2026-06-15T11:22:30+00:00

Having a slight problem with creating a .Net Session based variable. I know i

  • 0

Having a slight problem with creating a .Net Session based variable.

I know i can just use the Session extension and be done with it but i am looking more for a Multiple Browser (either Window or Tab, for IE) situation on a single desktop.

Currently, i have a Module declared in the Web-App and when i open up two individual Windows of IE they initially load the custom PageRouting design, as expected but once i go to the next step with both windows open, the last one to be opened is the design/logic used for the rest of the application.

Module.vb

Namespace classes
    Module Globals
        Public Brand As Brand
        Public Test As Test
        Public Results As Results
        Public Primary As String = "#FFFFFF"
        Public Secondary As String = "#FFFFFF"
        Public Terteruary As String = "#FFFFFF"

    End Module
End Namespace

In code, i reference the objects as Globals.Brand or Globals.Primary but in either case a situation where the same desktop could open up the same website with different PageRouting address, it assumes the last opened browser window.

The Brand & Test variables are initialized in the Session_Start event in Globals.asax. All references to these objects are explicit references using Globals.<variable> annotation when used. Results is initialized on first use during the execution of the website.

Question

  1. How do i make sure that each individual browser window is loaded with its own unique session cache for use with the site?

Updated – 2012-12-03

What about a design like this?

Public Class Class1
  private _sess as HTTPSessionState
  ...
  private readonly property Session as HttpSessionState
    Get
      if _sess is nothing then
        _sess = httpcontext.current.session
      end if
      return _sess
    End Get
  end property
  ...
  public property Primary as string
    Get
      return cstr(session("primary"))
    end get
    Set(value as string)
      session("primary") = value
    end set
  end property
  ...
end class

With Class1 being instantiated at the Master/Content page level?

Update #2 – 2012-12-03

Modified the module, let me know if this is a viable session control setup

Module Globals
    'Dictionary Collection of type (SessionID:String, Quiz:classes.Quiz)
    Public Quizzes As Dictionary(Of String, classes.Quiz)

    Public Property Quiz(session As String) As Quiz
        Get
            Return Quizzes(session)
        End Get
        Set(value As Quiz)
            Quizzes(session) = value
        End Set
    End Property

End Module

Final Form 2012-12-10:

Module.vb

Module Globals
    'Get/Set a Quiz object into the SessionState.
    Public Property Quiz(sess As HttpSessionState) As Quiz
        Get
            Return CType(sess("quiz"), Quiz)
        End Get
        Set(value As Quiz)
            sess("quiz") = value
        End Set
    End Property

End Module

Web.config

<system.web>
...
    <sessionState mode="InProc" cookieless="UseCookies" 
                  regenerateExpiredSessionId="true" timeout="20" 
                  cookieName="ASPNET_Quiz" />
...
</system.web>

The above form worked as expected utilizing the indexer aspect of a Property. Havent had any user instance problems. One side note, is that in order for this to work effectively the user must close all browser windows and open a new window for the session to clear out

  • 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-06-15T11:22:31+00:00Added an answer on June 15, 2026 at 11:22 am

    The problem you are coming across is a very common one in web programming. A Module’s members are static – meaning there is one instance of them across the entire AppDomain of your application. Every user that accesses these will get the same object.

    You could possibly replace the public variable in your module with a property whose getter you write to access a user-specific field in a dictionary (please remember thread safety when writing this getter code).

    The much easier solution would be to use the Session. Session values are stored server-side and are user specific. The only thing that get’s sent client side is the session key, and if you are using .Net authentication, this is likely already getting sent.

    Check this source:

    How to get a public variable (in a Module) to NOT share value between users

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

Sidebar

Related Questions

I'm having a slight problem that I can't figure out, but should be really
Having a slight problem on C#, still quite new to the language but hoping
I asked a similar question yesterday but still having a slight problem on output.
I am having a slight problem. I want a django app that can upload
having a slight problem with an ASP.net page of mine. If a user were
I'm having a slight problem with regex I'm trying to use on my JTextArea
Wondering if anyone can help me with this slight problem i'm having. I am
I'm having a slight problem with my SDL/Opengl code, specifically, when i try to
I am having a slight problem with gtk. I imported it into some python
I am coding this layout as a wordpress theme and having a slight problem

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.