Profile.IsAnonymous problem

Discussion in 'ASP .Net' started by Marco Assandri, Feb 9, 2006.

  1. Hi everybody,

    I have a problem with this code.

    'An anonymous username copied from the Username column of Aspnet_Users table
    with IsAnonymous = True

    dim SurelyAnonymousUsername = "b8119428-6420-4609-958b-ac0504f6f88b"
    dim p as ProfileCommon
    p = Profile.GetProfile(SurelyAnonymousUsername)

    If p.IsAnoymous = True then ' This is False ??????????????

    ......

    End If



    It is impossible. Why p.IsAnonymous is False??

    Thanks
     
    Marco Assandri, Feb 9, 2006
    #1
    1. Advertising

  2. Marco,

    When the profile system is running any user who comes to the site is added
    to the anonymous user table and is assigned a guid to track them. (Not so
    anonymous after all). The difference between an anonymous user and a
    registered user isn't that the anonymous user isn't in the database it's
    that the anonymous user isn't signed in. The code you are calling is
    returning false, because the guid can't be found in the database at all.
    Therefore the user isn't registered or anonymous.

    Is that clear? Let me know if my explanation isn't clear enough and I'll
    attempt to word it differently.

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
    "Marco Assandri" <> wrote in message
    news:...
    > Hi everybody,
    >
    > I have a problem with this code.
    >
    > 'An anonymous username copied from the Username column of Aspnet_Users
    > table with IsAnonymous = True
    >
    > dim SurelyAnonymousUsername = "b8119428-6420-4609-958b-ac0504f6f88b"
    > dim p as ProfileCommon
    > p = Profile.GetProfile(SurelyAnonymousUsername)
    >
    > If p.IsAnoymous = True then ' This is False ??????????????
    >
    > .....
    >
    > End If
    >
    >
    >
    > It is impossible. Why p.IsAnonymous is False??
    >
    > Thanks
    >
    >
     
    S. Justin Gengo [MCP], Feb 9, 2006
    #2
    1. Advertising

  3. Justin,
    the user is in the aspnet_Users table and the column IsAnonymous of this
    table is true.
    When I debug the application the code run fine.
    p = Profile.GetProfile(SurelyAnonymousUsername) return a real anonymous
    profile and I can use it to retrieve all information about this anonymous
    user.
    All works fine except the IsAnonymous properties.
    It's difficult to explain.
    Try this code in the pageLoad event of one page to see what I mean:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
    Handles Me.Load



    'Now I create a profile equal to the current profile

    Dim p As ProfileCommon = Profile.GetProfile(Profile.UserName)

    Response.Write(p.IsAnonymous)

    Response.Write("<br />")

    Response.Write(Profile.IsAnonymous)

    End Sub

    The result is:

    False
    True

    The p profile is not anonymous and the current profile is anonymous. But it
    is impossible because they are the same profile with the same properties
    except the IsAnonymous property.
    I hope to have explained the problem.


    "S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote in
    message news:%...
    > Marco,
    >
    > When the profile system is running any user who comes to the site is added
    > to the anonymous user table and is assigned a guid to track them. (Not so
    > anonymous after all). The difference between an anonymous user and a
    > registered user isn't that the anonymous user isn't in the database it's
    > that the anonymous user isn't signed in. The code you are calling is
    > returning false, because the guid can't be found in the database at all.
    > Therefore the user isn't registered or anonymous.
    >
    > Is that clear? Let me know if my explanation isn't clear enough and I'll
    > attempt to word it differently.
    >
    > --
    > Sincerely,
    >
    > S. Justin Gengo, MCP
    > Web Developer / Programmer
    >
    > www.aboutfortunate.com
    >
     
    Marco Assandri, Feb 9, 2006
    #3
  4. Marco,

    I think the following article addresses what you're talking about:

    http://odetocode.com/Articles/440.aspx

    Here's an excerpt:

    Notice we need to coerce the Profile object into a ProfileCommon reference
    (the as ProfileCommon in the code). Since the ProfileCommon class is
    generated by ASP.NET from web.config, so it's not possible for the
    HttpContext class to know the definition of ProfileCommon. HttpContext has
    to return a ProfileBase reference. The ProfileCommon class derives from
    ProfileBase. All we need to do is cast the ProfileBase reference to a
    ProfileCommon reference.

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
    "Marco Assandri" <> wrote in message
    news:%23$0e$...
    > Justin,
    > the user is in the aspnet_Users table and the column IsAnonymous of this
    > table is true.
    > When I debug the application the code run fine.
    > p = Profile.GetProfile(SurelyAnonymousUsername) return a real anonymous
    > profile and I can use it to retrieve all information about this anonymous
    > user.
    > All works fine except the IsAnonymous properties.
    > It's difficult to explain.
    > Try this code in the pageLoad event of one page to see what I mean:
    >
    > Protected Sub Page_Load(ByVal sender As Object, ByVal e As
    > System.EventArgs) Handles Me.Load
    >
    >
    >
    > 'Now I create a profile equal to the current profile
    >
    > Dim p As ProfileCommon = Profile.GetProfile(Profile.UserName)
    >
    > Response.Write(p.IsAnonymous)
    >
    > Response.Write("<br />")
    >
    > Response.Write(Profile.IsAnonymous)
    >
    > End Sub
    >
    > The result is:
    >
    > False
    > True
    >
    > The p profile is not anonymous and the current profile is anonymous. But
    > it is impossible because they are the same profile with the same
    > properties except the IsAnonymous property.
    > I hope to have explained the problem.
    >
    >
    > "S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote
    > in message news:%...
    >> Marco,
    >>
    >> When the profile system is running any user who comes to the site is
    >> added to the anonymous user table and is assigned a guid to track them.
    >> (Not so anonymous after all). The difference between an anonymous user
    >> and a registered user isn't that the anonymous user isn't in the database
    >> it's that the anonymous user isn't signed in. The code you are calling is
    >> returning false, because the guid can't be found in the database at all.
    >> Therefore the user isn't registered or anonymous.
    >>
    >> Is that clear? Let me know if my explanation isn't clear enough and I'll
    >> attempt to word it differently.
    >>
    >> --
    >> Sincerely,
    >>
    >> S. Justin Gengo, MCP
    >> Web Developer / Programmer
    >>
    >> www.aboutfortunate.com
    >>

    >
    >
     
    S. Justin Gengo [MCP], Feb 11, 2006
    #4
  5. Thanks Justin for your time,

    I found a solution.
    The ProfileCommon created by Profile.GetProfile(Username) are different from
    the HttpContext profile.
    They don't change automatically but I need to use the Save() sub.
    The IsAnonymous property return always false except with the HttpContext
    profile. To find if the different profile isAnonymous or not I did a query
    on the aspnet_Users table column IsAnonymous.
    Thanks for your help.
    Sincerely,
    Marco



    "S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote in
    message news:%...
    > Marco,
    >
    > I think the following article addresses what you're talking about:
    >
    > http://odetocode.com/Articles/440.aspx
    >
    > Here's an excerpt:
    >
    > Notice we need to coerce the Profile object into a ProfileCommon reference
    > (the as ProfileCommon in the code). Since the ProfileCommon class is
    > generated by ASP.NET from web.config, so it's not possible for the
    > HttpContext class to know the definition of ProfileCommon. HttpContext has
    > to return a ProfileBase reference. The ProfileCommon class derives from
    > ProfileBase. All we need to do is cast the ProfileBase reference to a
    > ProfileCommon reference.
    >
    > --
    > Sincerely,
    >
    > S. Justin Gengo, MCP
    > Web Developer / Programmer
    >
    > www.aboutfortunate.com
    >
    > "Out of chaos comes order."
    > Nietzsche
    > "Marco Assandri" <> wrote in message
    > news:%23$0e$...
    >> Justin,
    >> the user is in the aspnet_Users table and the column IsAnonymous of this
    >> table is true.
    >> When I debug the application the code run fine.
    >> p = Profile.GetProfile(SurelyAnonymousUsername) return a real anonymous
    >> profile and I can use it to retrieve all information about this anonymous
    >> user.
    >> All works fine except the IsAnonymous properties.
    >> It's difficult to explain.
    >> Try this code in the pageLoad event of one page to see what I mean:
    >>
    >> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
    >> System.EventArgs) Handles Me.Load
    >>
    >>
    >>
    >> 'Now I create a profile equal to the current profile
    >>
    >> Dim p As ProfileCommon = Profile.GetProfile(Profile.UserName)
    >>
    >> Response.Write(p.IsAnonymous)
    >>
    >> Response.Write("<br />")
    >>
    >> Response.Write(Profile.IsAnonymous)
    >>
    >> End Sub
    >>
    >> The result is:
    >>
    >> False
    >> True
    >>
    >> The p profile is not anonymous and the current profile is anonymous. But
    >> it is impossible because they are the same profile with the same
    >> properties except the IsAnonymous property.
    >> I hope to have explained the problem.
    >>
    >>
    >> "S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote
    >> in message news:%...
    >>> Marco,
    >>>
    >>> When the profile system is running any user who comes to the site is
    >>> added to the anonymous user table and is assigned a guid to track them.
    >>> (Not so anonymous after all). The difference between an anonymous user
    >>> and a registered user isn't that the anonymous user isn't in the
    >>> database it's that the anonymous user isn't signed in. The code you are
    >>> calling is returning false, because the guid can't be found in the
    >>> database at all. Therefore the user isn't registered or anonymous.
    >>>
    >>> Is that clear? Let me know if my explanation isn't clear enough and I'll
    >>> attempt to word it differently.
    >>>
    >>> --
    >>> Sincerely,
    >>>
    >>> S. Justin Gengo, MCP
    >>> Web Developer / Programmer
    >>>
    >>> www.aboutfortunate.com
    >>>

    >>
    >>

    >
    >
     
    Marco Assandri, Feb 12, 2006
    #5
    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. Brad
    Replies:
    1
    Views:
    1,141
    Roedy Green
    Jul 19, 2005
  2. Replies:
    1
    Views:
    1,904
  3. kal
    Replies:
    0
    Views:
    318
  4. Andy B
    Replies:
    0
    Views:
    522
    Andy B
    May 3, 2008
  5. C# programmer

    IsAnonymous Column in dbo.aspnet_Users

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

Share This Page