无法检测会话变量是否存在
我的代码是:
if session("something") then end if
任何验证方法?
问候
答案 0 :(得分:2)
假设这是VB.NET:
If Not (session("something") Is Nothing) Then
' use session("something")
End If
答案 1 :(得分:1)
VB.NET:
If session("whatever") is nothing then
do something
Else
do something else
End if
将此代码放在Page_Load()
中if(Session["SessionName"] == null)
{
//Session Does not Exists
}
else
{
//Session Exists
}
或参考:
What is the best way to determine a session variable is null or empty in C#?