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

Profile.IsAnonymous problem

P: n/a
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
Feb 9 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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" <no****@nospam.com> wrote in message
news:e4**************@TK2MSFTNGP11.phx.gbl...
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

Feb 9 '06 #2

P: n/a
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:%2****************@TK2MSFTNGP12.phx.gbl...
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

Feb 9 '06 #3

P: n/a
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" <no****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
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:%2****************@TK2MSFTNGP12.phx.gbl...
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


Feb 11 '06 #4

P: n/a
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:%2****************@TK2MSFTNGP11.phx.gbl...
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" <no****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
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:%2****************@TK2MSFTNGP12.phx.gbl...
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



Feb 12 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.