newbie: check if user is a anonymous user

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
 
P

PeterKellner

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top