title: How much resources does it take to call and read from Session object in ASP.NET?
body: <p>I was wondering how wasteful is calling Session object like these (example):</p>
  
  <pre><code>string test = string.Empty;
  for (int i = 0; i &lt; 1000; i++)
  {
     test += Session["test"].ToString() + ",";
  }
  </code></pre>
  
  <p>Instead of like these:</p>
  
  <pre><code>string test = string.Empty;
  string test_session_value = Session["test"].ToString();
  for (int i = 0; i &lt; 1000; i++)
  {
     test += test_session_value + ",";
  }
  </code></pre>
  
  <p>(that is calling <code>HttpSessionState</code> object and reading session from it multiple times rather than just as fewer times as possible)</p>
  
  <p>Is there any performance penalty (noticeable)? How much should developer be careful with <code>HttpSessionState</code> object usage?</p>