Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Profile.IsAnonymous problem

Reply
Thread Tools

Profile.IsAnonymous problem

 
 
Marco Assandri
Guest
Posts: n/a
 
      02-09-2006
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


 
Reply With Quote
 
 
 
 
S. Justin Gengo [MCP]
Guest
Posts: n/a
 
      02-09-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Marco Assandri
Guest
Posts: n/a
 
      02-09-2006
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:%(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
S. Justin Gengo [MCP]
Guest
Posts: n/a
 
      02-11-2006
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" <(E-Mail Removed)> wrote in message
news:%23$0e$(E-Mail Removed)...
> 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:%(E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
Marco Assandri
Guest
Posts: n/a
 
      02-12-2006
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:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%23$0e$(E-Mail Removed)...
>> 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:%(E-Mail Removed)...
>>> 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
>>>

>>
>>

>
>



 
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
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM



Advertisments