Anu

Anu

  • 1.5k
  • 194
  • 8.5k

How to clear global variable in mvc

Sep 10 2024 12:00 PM

Hi,

I have a requirement to use global variable in MVC application, which is created using the below code. This valirable is assigned at the login time and is cleared at the time of logout. By mistake if we close the whole browser, then the variable is holding the value at the time of login. Is there any way to identify if the browser or tab is closed for making null to the variable

public static class GlobalVariable
    {
        static string _Id;
        public static string _ID
        {
            get
            {
                return _Id;
            }
            set
            {
                _Id = value;
            }
        }


Answers (4)