Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Profile.IsAnonymous always = true

Reply
Thread Tools

Profile.IsAnonymous always = true

 
 
robertm@performancematerials.com
Guest
Posts: n/a
 
      06-08-2007
Hello.

I have enabled Membership on my .NET application. I can add users,
assign them to roles, and log in and out.
the roles work perfectly, however the following code:

bool amIloggedIn = Profile.IsAnonymous;

amIloggedIn is alway = true;

whether I am logged in or not the isAnonymous property in the profile
is alway true, and the username does not get set, but the roles
provider recognized that I am logged in and gives me access to
restricted sub-directories.

Can anyone help me out here?

 
Reply With Quote
 
 
 
 
robertm@performancematerials.com
Guest
Posts: n/a
 
      06-11-2007
On Jun 8, 2:46 pm, (E-Mail Removed) wrote:
> Hello.
>
> I have enabled Membership on my .NET application. I can add users,
> assign them to roles, and log in and out.
> the roles work perfectly, however the following code:
>
> bool amIloggedIn = Profile.IsAnonymous;
>
> amIloggedIn is alway = true;
>
> whether I am logged in or not the isAnonymous property in the profile
> is alway true, and the username does not get set, but the roles
> provider recognized that I am logged in and gives me access to
> restricted sub-directories.
>
> Can anyone help me out here?


I found a solution:

I think the problem is being caused by Context Issues. I am using a
MasterPage, and so when I login in, and I successfully logged in,
however when I go to another page the Profile is empty because the
context is different.

Work around:

To use the Profile, we need to re-initialize it:

if (Request.IsAuthenticated)
{
Profile.Initialize(User.Identity.Name, true);
}

Keep in mind this will only work with forms based authentication.

 
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
[False,True] and [True,True] --> [True, True]????? bdb112 Python 45 04-29-2009 02:35 AM
IsValid always returns true on server-side under FireFox 0.9 Jeremy ASP .Net 2 07-01-2004 02:43 PM
Trying to create a CSS box that is always is always the width of an image placed inside it (and no wider) Deryck HTML 4 06-22-2004 08:25 PM
Manual Validate call always returns IsValid=true Jon Davis ASP .Net 3 01-27-2004 10:14 PM
Manual Validate() call always returns IsValid=true Jon Davis ASP .Net 1 01-27-2004 08:51 PM



Advertisments