我无法检测会话变量是否存在

时间:2014-05-27 22:04:01

标签: vb.net

无法检测会话变量是否存在

我的代码是:

if session("something") then end if

任何验证方法?

问候

2 个答案:

答案 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#?

相关问题