怎么判断Session的值是否为空,并取出Session的值

用户登录有赋值Session["name"] = txtUserName.Text;然后怎么取出Session["name"]中的值,并能用if语句进行判断是否为空。如果不为空赋值到Label2中
2026年09月21日 21:41
有1个网友回答
网友(1):

能的

if(Session["name"] != NULL){
    label2.text = Session["name"].toString();
}