Profile.IsAnonymous always = true

Discussion in 'ASP .Net' started by robertm@performancematerials.com, Jun 8, 2007.

  1. Guest

    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, 2007
    #1
    1. Advertising

  2. Guest

    On Jun 8, 2:46 pm, 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, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marco Assandri

    Profile.IsAnonymous problem

    Marco Assandri, Feb 9, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    2,587
    Marco Assandri
    Feb 12, 2006
  2. Brad
    Replies:
    1
    Views:
    1,143
    Roedy Green
    Jul 19, 2005
  3. kal
    Replies:
    0
    Views:
    318
  4. bdb112
    Replies:
    45
    Views:
    1,354
    jazbees
    Apr 29, 2009
  5. C# programmer

    IsAnonymous Column in dbo.aspnet_Users

    C# programmer, Feb 13, 2007, in forum: ASP .Net Security
    Replies:
    1
    Views:
    206
    Nasser Dassi
    Feb 19, 2007
Loading...

Share This Page