newbie: check if user is a anonymous user

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

hey

asp.net 2.0

How can I from the code check if a user is a anonymous user or a loggedin
user...

I guess there must be a better way of doing it than this:
if (Profile.UserName == null) {
//user is anonymous
}

I have a loginview in my webpage, maybe the loginview have some methods or
properties for this... I need to know how to check this from the code
page...... .cs files

Any suggestions?

Jeff
 
hey

asp.net 2.0

How can I from the code check if a user is a anonymous user or a loggedin
user...

I guess there must be a better way of doing it than this:
if (Profile.UserName == null) {
//user is anonymous
}

I have a loginview in my webpage, maybe the loginview have some methods or
properties for this... I need to know how to check this from the code
page...... .cs files

Any suggestions?

Jeff

How about this:

IPrincipal iPrincipal = HttpContext.Current.User;
if (iPrincipal.Identity.IsAuthenticated)
{
authenticated = true;
...
Peter Kellner
http://peterkellner.net
 
Back
Top