Tôi muốn kiểm tra phiên đó là null hoặc rỗng tức là một số điều như thế này:Kiểm tra phiên làm việc nếu có sản phẩm nào hay không
if(Session["emp_num"] != null)
{
if (!string.IsNullOrEmpty(Session["emp_num"].ToString()))
{
//The code
}
}
Hoặc chỉ cần
if(Session["emp_num"] != null)
{
// The code
}
vì đôi khi tôi chỉ kiểm tra với:
if (!string.IsNullOrEmpty(Session["emp_num"].ToString()))
{
//The code
}
Tôi phải đối mặt ing ngoại lệ:
Null Reference ngoại lệ
có một cái nhìn vào bài đăng này http://stackoverflow.com/questions/234973/what-is-the-best-way-to-determine-a-session-variable-is-null -hoặc-trong-c – Bobby
thực sự tốt đẹp, cảm ơn rất nhiều. –