 |
| ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 20th, 2007, 03:50 PM
|
|
Friend of Wrox
|
|
Join Date: Mar 2006
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Get my Anonymous username or userID
Hello!
In my webconfig file I have:
Code:
<anonymousIdentification cookieless="AutoDetect" enabled="true"/>
I don't want to define any others properties for anonymous...
But I saw in aspnet_membership and aspnet_users table that my system save the userid and the username of anonymous users...
How can I get the Anounymous UserName ?
I think one of them (UserID or Username) will be stored in cookies...
How can I get this values?
I tried this:
userName = HttpContext.Current.User.Identity.Name
But, of course this only work for registered users...
Thanks very much!
Max
|
|

October 20th, 2007, 05:15 PM
|
|
Friend of Wrox
|
|
Join Date: Mar 2006
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks one more time Imar!
It's exactly what i want!!
|
|

October 21st, 2007, 04:27 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2006
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Upps I have another doubt about this!
I made some checks and I saw that If I open my application as anonymous I preserve my anonymousID but If I login with my username and then logout, when I re-check my anonymousID I see that it's not the same anonymousID as the first time :(
Is it normal? Or I have some quickly way to make my anonymousID come back to the "old" one after my logout?
Thanks!
Max
http://asp.net/AJAX/Documentation/Li...SPNETAJAX.aspx
|
|

October 21st, 2007, 04:33 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
I am not sure, but I don't think so. AFAIK, the anonymous cookie is cleared when you log in, because you are no longer anonymous.
I think that's why it's called an Anonymous Id; you can't really rely on it being there, as users can easily kill their cookies and be a new user.
Can't you keep track of your own ID with another cookie?
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
|
|

October 21st, 2007, 05:10 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2006
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ok!
I understand!
Yes, I could create another cookie to preserve anonymous but i'm thinking and it's better getting a clean cookie!
I'm building a webforum and I want to save all topics views by user.
For example, when I open this thread, I will save on db that ME(with my username) saw this topic at this hour.
(But When I enter First time I delete all the records where my Username and my SessionID match)
Then, when I select threads list, i need to send my username too with this request! And the database will see for each thread the last time that I saw the current thread. With this I can retrieve another column if the thread is new or not... (Just for threads with lastPostdate > myUserLastVisit)
I want that can work for anonymous too... BUT if I preserve anonymousID I have this scenario:
Open the forum as guest I see the new threads.
Login to my username and see the new threads
Navigate to some threads... And pass the value IsNew to IsRead...
Then, when I migrate to anonymous Ill see the threads that I already saw as "IsNew"
If I made a clean anonymousID I prevent this!
I need only be concerned about clearing my Forums_Members Table & my Forums_MbrViews table because I'll generate more rows with the anonymous!
Thanks one more time Imar!
|
|

October 21st, 2007, 08:17 AM
|
|
Friend of Wrox
|
|
Join Date: Mar 2006
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I create that too! Not in cookie but in session!
For all threadsList and SubForums and Forums I need to know if lastPostDate is earlier or not than lastVisit!
But after that I need to know if the current user already saw this thread... Or if a forum has any thread that the user hasn't already visit...
For that I must save (I choose save on DB) everytime one user saw a thread, his lastVisit (bysessionVar) and his sessionID and of course something who identify him (Username or AnonymousID)
Only lastvisit Cookie or session will only display new posts since lastvisit!
No matter if the user already see them or not they will be always new posts!
I wondered if was more useful save the Posts sawed in one hashtable on session but... I decided to use DB because with that I do all the routines in DB and only retrieve (isNew = true or false...)
(I never imagined that I have so much work to do and so many things to think for this! but I almost finish... :) )
I'm building a webforum like this but with more options like private messages, poll's, avatars, statistics, subforums, etc...
|
|
 |