title: Alternative to HttpContext.Current.Items
body: <p>Recently, I discovered a bug in our system where a property in a dll was shared. In the case of ASP.Net, this caused issues with thread safety.</p>
  
  <pre><code>protected static object Data { get; set; }
  </code></pre>
  
  <p>In order to fix this with the smallest change possible, I swapped out the inner property to make use of <code>HttpContext.Current.Items</code> to store and retrieve the value. This works in the case of our website(s).</p>
  
  <pre><code>protected static object Data
  {
      get
      {
          return HttpContext.Current.Items[DataKey] as object;
      }
      set
      {
          HttpContext.Current.Items[DataKey] = value;
      }
  }
  </code></pre>
  
  <p>However, we also have an exe that references this dll. When this runs it (obviously) does not have a reference to <code>HttpContext.Current</code>.</p>
  
  <p>Is there an alternative object I can use that will work for both asp.net and/or the exe. I'm willing to use branching logic to work out which property to hit if necessary, so long as I only need to change this property (obviously one solution for both is preferred.</p>