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.

4

1 回答 1

0

http://msdn.microsoft.com/en-us/library/ewfkf772(v=vs.100).aspx拥有一切。

使用它来迁移 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);

}
于 2013-08-08T07:25:34.250 回答