I want to use anonymous profiles to store and use profile data without authenticated. How to enable anonymous profiles is described on page https://msdn.microsoft.com/en-us/library/ewfkf772(v=vs.100).aspx
Profiles can also work with anonymous users. Support for anonymous profiles is not enabled by default, so you must explicitly enable it. In addition, when you define profile properties in the Web.config file, you must explicitly make them available individually for anonymous users. Profile properties do not support anonymous access by default because profiles may be designed to work with authenticated users, and many properties are likely to pertain to personal information that is not available for anonymous users.
But I'm not sure, that I can use profile data for anonymous users. It says, that by default I can't use profile data. But not by default, have I ability to use profile data for anonymous users and if "yes" then what should I do? I confused...
Answer
Anonymous profiles are possible. They let us associate profile data (e.g. a postal code) with an anonymous user. Of course, the profile data is only relevant while ASP.NET can identify the anonymous user via a cookie (or a query string parameter) like this:
We can. I've just tested this on my local machine with ASP.NET MVC.
First, add the following to the
system.web
section of the web.config file. It tells ASP.NET to track anonymous users, add a single profile property, and configure the provider with our default DB connection (assuming we have a connection string namedDefaultConnection
.)Once we've done that, ASP.NET will allow us to get/set profile properties as follows:
Note: you must setup Profiles on your database for this to work (otherwise ASP.NET will complain that it cannot find stored procedures.) One way to setup Profiles is to run
aspnet_regsql
on your database like this.For more info about the
aspnet_regsql
flags, runaspnet_regsql -?
for documentation. The-A p
sets up Profiles and the-E
uses integrated security.See also:
For other approaches and more details, here are some other links: