Identify anonymous users in asp.net
The first thing when we read about identifying anonymous users in asp.net mvc is "Why do we need to identify anonymous users?". Well the same thought had crossed my mind, but then when developing an e-commerce application, we needed anonymous users to add items to the shopping cart without logging in. We also needed these items to be loaded into the shopping cart, the next time they visited.
How do we do this?
Asp.net provides a guid accessed through the Request.AnonymousId property with which the user can be identified.
Enable anonymous Identification
Anonymous Identification need to be enabled, else Request.AnonymousId will be null.
<configuration>
<system.web>
<anonymousIdentification enabled="true"/>
</system.web>
</configuration>
Access the Anonymous Id
Anonymous Id can be accessed through Request.AnonymousID property.
No comments:
Post a Comment