【发布时间】:2012-05-14 16:51:07
【问题描述】:
我想知道这样调用 Session 对象有多浪费(示例):
string test = string.Empty;
for (int i = 0; i < 1000; i++)
{
test += Session["test"].ToString() + ",";
}
而不是像这样:
string test = string.Empty;
string test_session_value = Session["test"].ToString();
for (int i = 0; i < 1000; i++)
{
test += test_session_value + ",";
}
(即调用HttpSessionState 对象并从中多次读取会话,而不是尽可能少地读取)
是否有任何性能损失(明显)?开发者在使用HttpSessionState 对象时应该注意多少?
【问题讨论】:
标签: asp.net performance optimization