By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,214 Members | 2,099 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,214 IT Pros & Developers. It's quick & easy.

Profile.IsAnonymous always = true

P: n/a
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?

Jun 8 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Jun 8, 2:46 pm, robe...@performancematerials.com 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.

Jun 11 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.