Click here to Skip to main content
16,021,115 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hai,

I am working with session variable. But, when the session is in null null reference error is showing . How to check session in if loop.

Regards,
Manu.
Posted
Comments
Varun Sareen 25-Feb-12 2:13am    
paste some code

Check if session attributes are not null before accessing them
e.g. if (Session["sesloginId"] != null)
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 26-Feb-12 12:46pm    
Logical, isn't it? My 5.
--SA
C#
if (Session["sesloginId"].ToString() != "")
                {
                  }
 
Share this answer
 
in other pages which you want to retrieve session value just write in page load event if(Session.Count>0)
{
and write your session value here
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900