title: asp.net mvc setting session values with thread safety
body: <p>In my asp.net MVC project, I have a session helper class that I use to set and retrieve session values. This is the class:</p>
  
  <pre><code>public class SessionManager
  {
       public static string UserName
      {
          get
          {
              return HttpContext.Current.Session[SessConstants.UName] ;
          }
          set
          {
              HttpContext.Current.Session[SessConstants.UName] = value;
          }
      }
  }
  </code></pre>
  
  <p>As you can see the properties are static. I use this in my code as below:</p>
  
  <pre><code>//For setting values    
  SessionManager.UserName = "";
  
  //For retrieving values
  strLoggedinUser = SessionManager.UserName;
  </code></pre>
  
  <p>Questions: </p>
  
  <ol>
  <li>Are static properties like these thread safe for setting to HttpContext.Current.Session['someVar'] ?</li>
  <li>Should I create a instance property instead and instantiate the SessionManager in a base controller which I inherit from the MVC controller class. I can then have all my controllers inherit my custom controller instead of the MVC one</li>
  </ol>
  
  <p>Thoughts? </p>
  
  <p>Thanks for your time...</p>