如何在mvc应用程序中处理匿名用户

本文关键字:处理 用户 应用程序 mvc | 更新日期: 2023-09-27 18:26:53

我正在创建一个Asp.NET MVC-4应用程序。在我的应用程序中,用户可以发布他们的产品。我希望无论用户是否登录[匿名者],他都可以在那里发布产品。为此,我可以使用SessionId,但我担心如果会话过期,我如何检测匿名用户。

我想了解有关将匿名配置文件迁移到已登录的用户配置文件的信息。请给我推荐一些好的教程或资源或逻辑,我可以通过它们来实现这一点。

如何在mvc应用程序中处理匿名用户

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

使用此迁移Global.asax 中的rhe配置文件

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);
}