BeanSoftware Logo
 

 
ASP.NET Database Search Control
 
 

 
 Home
    Shop
    Advertise
    Write For Us
    Affiliate
    Newsletter
    Contact

How to Find If User Is Logged In?

If your web application uses membership, then you need to know if web request is authenticated or not. To find is user currently logged in use this code:

[ C# ]

// To check if user is logged in use
// IsAuthenticated property
if (Context.User.Identity.IsAuthenticated)
{
  // User is logged in
           
}
else
{
  // Anonymous request
           
}

[ VB.NET ]

' To check if user is logged in use
' IsAuthenticated property
If (Context.User.Identity.IsAuthenticated) Then
  ' User is logged in
 
Else
  ' Anonymous request
 
End If

On the same way, you can also use Request.IsAuthenticated method instead of User.Identity.IsAuthenticated.



Related articles:

1. User registration and authentication for an ASP.NET 2.0 webs
2. How to Logout User in ASP.NET Membership?
3. How to Show User Name of Currently Logged User?

FAQ toolbar: Submit FAQ  |  Tell A Friend  |  Add to favorites  |  Feedback



Copyright © 2002-2008 Bean Software. All rights reserved.