title: ASP.NET OWIN vs Singleton Pattern
body: <p>I'm working on a Web App where I instantiated my a Singleton class below in Startup.cs in order to be reused (more like making a programmable session):</p>
  
  <pre><code> app.CreatePerOwinContext&lt;XYZManager&gt;(XYZManager.Create);
  </code></pre>
  
  <p>But I'm encountering a problem, as soon as UserA logs in on the app, the information inside XYZManager class gets overwritten when UserB enters and vice versa when they perform some action.</p>
  
  <p>The problem I think is, they're sharing the same application pool, how can this be resolve, any hack?</p>
  
  <p>An meanwhile the whole essence of this approach, I want to be able to call any getter / setter of method inside XYZManager for the current logged user for example:</p>
  
  <pre><code>HttpContext.GetOwinContext().Get&lt;XYZManager&gt;().GetFullDetails();
  </code></pre>
  
  <p>But sometimes throw details for another logged on user based on operations.</p>
  
  <pre><code> public class XYZManager : IDisposable
   {
       private static XYZManager instance  { get; set; }
       public static  XYZManager Create()
       {
          var xyzManager = instance ?? (instance = new XYZManager());
          xyzManager.ApplicationDbContext = new ApplicationDbContext();
          return xyzManager;
       }
       public string GetFullDetails () {
          return "blah blah";
       }
   }
  </code></pre>