How to Check Save User's Credendiatals in Session in C#? Does anyone know how can I check whether a session is empty or null in .net c# web-applications?
Asked
Active
Viewed 1,424 times
1
-
Did you try Session["User"] != null – Sami Jun 27 '16 at 04:05
2 Answers
1
Try this
if( Session["User"] == null || string.IsNullOrEmpty(Session["User"].ToString()))
{
//return to login ;
}
else
{
// your default page
}
sujith karivelil
- 27,818
- 6
- 51
- 82
Nazir Ullah
- 600
- 3
- 13
0
if(Session["User"] !=null){
Response.Redirect("http://www.google.com",true);
}
else
{
Response.Redirect("~/login",true);
}
Sami
- 3,464
- 3
- 16
- 26