title: Replacing static variables in .net web application
body: <p>I don't have a problem, but I'm trying to prevent a problem from occurring in the future and would like a little help figuring out the proper way to approach this. I have a vendor who will be posting XML to a webpage that I have created. This would happen potentially every 2 minutes. The web page will then read the XML posted and insert into a Database. 
  Serializing the XML and inserting is not good enough so I have to do a little bit of parsing before I send the data to the database. I created a static class that looks like the following.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  
  /// &lt;summary&gt;
  /// Summary description for Accounting
  /// &lt;/summary&gt;
  public static class Accounting
  {
      public static String currentFile = "";
      public static List&lt;string&gt; PurchaseOrder = new List&lt;string&gt;();
      public static List&lt;string&gt; item = new List&lt;string&gt;();
      public static List&lt;string&gt; unitPrice = new List&lt;string&gt;();
      public static List&lt;string&gt; shippingCharge = new List&lt;string&gt;();
      public static List&lt;string&gt; handlingCharge = new List&lt;string&gt;();
      public static List&lt;string&gt; discountAmount = new List&lt;string&gt;();
      public static List&lt;string&gt; UOM = new List&lt;string&gt;();
      public static List&lt;string&gt; invoiceNumber = new List&lt;string&gt;();
      public static List&lt;string&gt; supplierNumber = new List&lt;string&gt;(); //{ get; set; }
      public static List&lt;string&gt; supplierInvoiceNo = new List&lt;string&gt;();
      public static List&lt;string&gt; account = new List&lt;string&gt;();
      public static List&lt;string&gt; fund = new List&lt;string&gt;();
      public static List&lt;string&gt; org = new List&lt;string&gt;();
      public static List&lt;string&gt; prog = new List&lt;string&gt;();
      public static List&lt;string&gt; activity = new List&lt;string&gt;();
      public static List&lt;string&gt; location = new List&lt;string&gt;();
      public static List&lt;string&gt; distributionType = new List&lt;string&gt;();
      public static List&lt;string&gt; distributionValue = new List&lt;string&gt;();
      public static List&lt;int&gt; sequence = new List&lt;int&gt;();
      public static List&lt;string&gt; quantity = new List&lt;string&gt;();
      public static List&lt;string&gt; dueDate = new List&lt;string&gt;();
  }
  </code></pre>
  
  <p>This class is static because I need to operate on the variables from different methods. 
  Now here is where things get tricky, I keep reading that if I use static variable in a .NET web application I will end up sharing the variable across sessions. This could potentially be a nightmare for me. so I looked into the singleton pattern and I have also found this <a href="https://stackoverflow.com/questions/5219431/static-variables-in-web-applications">Static variables in web applications</a> solution throught stackover flow.
     I read that I should do something like this</p>
  
  <pre><code>public class SingletonPerRequest
  {
      public static SingletonPerRequest Current
      {
          get
          {
              return (HttpContext.Current.Items["SingletonPerRequest"] ??
                  (HttpContext.Current.Items["SingletonPerRequest"] = 
                  new SingletonPerRequest())) as SingletonPerRequest;
  
          }
      }
  }
  </code></pre>
  
  <p>My problem is that I don't know how can I convert my class to basically do what the above is doing. In other words how do I set class to follow this singleton request pattern. Forgive my stupidity if this does not make sense. My ultimate goal would be to have every request to the page have its own session of accounting variables and not get shared across session. 
  Any help would be greatly appreciated.</p>