Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 20th, 2007, 03:50 PM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

  #2 (permalink)  
Old October 20th, 2007, 04:15 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Take a look at Request.AnonymousID that gives you the user's "name" (a Guid) as a string.

HtH,

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
  #3 (permalink)  
Old October 20th, 2007, 05:15 PM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks one more time Imar!

It's exactly what i want!!


  #4 (permalink)  
Old October 21st, 2007, 04:27 AM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

  #5 (permalink)  
Old October 21st, 2007, 04:33 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
  #6 (permalink)  
Old October 21st, 2007, 05:10 AM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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!
  #7 (permalink)  
Old October 21st, 2007, 05:50 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

How about creating a cookie LastVisit that takes care of all this?

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
  #8 (permalink)  
Old October 21st, 2007, 08:17 AM
Friend of Wrox
 
Join Date: Mar 2006
Location: , , Portugal.
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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...

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
About Anonymous Identification Lee Dumond BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 15 December 14th, 2008 05:12 PM
This property can not be set for anonymous users everest ASP.NET 2.0 Professional 2 April 19th, 2008 04:28 AM
Webpart in Anonymous Access site arunduttgp SharePoint Development 0 December 21st, 2007 01:56 AM
Session not working for Anonymous users songsan General .NET 0 January 4th, 2005 02:57 PM



All times are GMT -4. The time now is 05:12 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.