0

I am creating an Asp.NET MVC-4 application. In my application user can post their products. I want that whether user logged in or not [Anonymous] , he could post there products. For this i can use SessionId, but i am worry about if session expires that how can i detect the anonymous user.

I want to know about Migrating the Anonymous profile to logged in Userprofile. Please suggest me some good tutorials or resources or logic by which i can implement this.

Mathias F
  • 15,906
  • 22
  • 89
  • 159
user1740381
  • 2,121
  • 8
  • 37
  • 61

1 Answers1

0

http://msdn.microsoft.com/en-us/library/ewfkf772(v=vs.100).aspx has it all.

Use this to migrate rhe profiles in Global.asax

public void Profile_OnMigrateAnonymous(object sender, ProfileMigrateEventArgs args)
{
  ProfileCommon anonymousProfile = Profile.GetProfile(args.AnonymousID);

  Profile.ZipCode = anonymousProfile.ZipCode;
  Profile.CityAndState = anonymousProfile.CityAndState;
  Profile.StockSymbols = anonymousProfile.StockSymbols;

  ////////
  // Delete the anonymous profile. If the anonymous ID is not 
  // needed in the rest of the site, remove the anonymous cookie.

  ProfileManager.DeleteProfile(args.AnonymousID);
  AnonymousIdentificationModule.ClearAnonymousIdentifier(); 

  // Delete the user row that was created for the anonymous user.
  Membership.DeleteUser(args.AnonymousID, true);

}
Mathias F
  • 15,906
  • 22
  • 89
  • 159
  • Thanks for reply but i am working with SimpleMembershipProvider, is there any way, by which i can handle anonymous user without using Profile or any other new technology for handling anonymous user data. Because i believe profile is bit old, isn't ? – user1740381 Aug 08 '13 at 07:30
  • I am not shure if Profile_OnMigrateAnonymous gets called then. But I guess so. Anyway check out http://joeandcode.net/simplemembershipprovider-does-not-cater-for-anonymous-users – Mathias F Aug 09 '13 at 12:20
  • It is realy not there: check http://aspnetwebstack.codeplex.com/workitem/384 You should use the full blown MembershipProvider – Mathias F Aug 09 '13 at 12:25