I was wondering how wasteful is calling Session object like these (example):
string test = string.Empty;
for (int i = 0; i < 1000; i++)
{
test += Session["test"].ToString() + ",";
}
Instead of like these:
string test = string.Empty;
string test_session_value = Session["test"].ToString();
for (int i = 0; i < 1000; i++)
{
test += test_session_value + ",";
}
(that is calling HttpSessionState
object and reading session from it multiple times rather than just as fewer times as possible)
Is there any performance penalty (noticeable)? How much should developer be careful with HttpSessionState
object usage?