Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > newbie: check if user is a anonymous user

Reply
Thread Tools

newbie: check if user is a anonymous user

 
 
Jeff
Guest
Posts: n/a
 
      07-09-2006
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


 
Reply With Quote
 
 
 
 
PeterKellner
Guest
Posts: n/a
 
      07-09-2006
On Sun, 9 Jul 2006 17:56:24 +0200, "Jeff"
<(E-Mail Removed)> wrote:

>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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      07-09-2006
I think you missed the IsAnonymous property of the Profile Class.
Cheers,
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




"Jeff" wrote:

> 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
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to check whether user put a check in a toolbox CheckBox contro JB ASP .Net 1 08-26-2009 11:18 PM
Is this a local anonymous class or a member anonymous class Reporter Java 3 05-12-2007 05:23 AM
help with an anonymous array of anonymous hashes noeldamonmiller@gmail.com Perl Misc 1 02-10-2005 01:08 AM
website connection to database time out problem : login failed for user 'NT AUTHORITY\ANONYMOUS LOGON' Maellic ASP .Net 3 01-13-2004 06:21 AM
IIS anonymous user is a domain user Henry Splatt Computer Security 2 09-05-2003 10:43 AM



Advertisments