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,579 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
- 28,671
- 6
- 55
- 88

Nazir Ullah
- 610
- 5
- 13
0
if(Session["User"] !=null){
Response.Redirect("http://www.google.com",true);
}
else
{
Response.Redirect("~/login",true);
}

Sami
- 3,686
- 4
- 17
- 28