我支持一个遗留应用程序,我看到这样的代码:
'Use Session for everything?
If Session("UserType") = "Admin" Then
'do admin something
ElseIf Session("UserType") = "Manager" Then
'do manager stuff
ElseIf Session("UserType") = "User" Then
'do regular stuff
Else
'do anonymous stuff
End If
声明一个局部变量,将会话变量分配给局部变量,然后使用局部变量进行测试会更快更好地提高性能吗?
'Use local variable?
Dim UT As String = Session("UserType")
If UT = "Admin" Then
'do admin something
ElseIf UT = "Manager" Then
'do manager stuff
ElseIf UT = "User" Then
'do regular stuff
Else
'do anonymous stuff
End If
还是 IIS 为当前执行的代码检索到 Session 变量值后会自动缓存它吗?