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

C# 如何在mvc应用程序中处理匿名用户?,c#,asp.net-mvc,simplemembership,C#,Asp.net Mvc,Simplemembership,我正在创建一个Asp.NET MVC-4应用程序。在我的应用程序中,用户可以发布他们的产品。我希望无论用户是否登录[匿名],他都可以在那里发布产品。为此,我可以使用SessionId,但我担心如果会话过期,如何检测匿名用户 我想知道如何将匿名配置文件迁移到登录的Userprofile。请给我推荐一些好的教程、资源或逻辑,我可以通过它们来实现这一点。一切都准备好了 使用此选项迁移Global.asax中的rhe配置文件 public void Profile_OnMigrateAnonymous(

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

我想知道如何将匿名配置文件迁移到登录的Userprofile。请给我推荐一些好的教程、资源或逻辑,我可以通过它们来实现这一点。

一切都准备好了

使用此选项迁移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);

}

感谢回复,但我正在使用SimpleMembershipProvider,是否有任何方法可以处理匿名用户,而无需使用配置文件或任何其他新技术来处理匿名用户数据。因为我相信profile有点过时了,不是吗?如果profile_on MigrateAnonymous当时被呼叫,我就不是舒尔了。但我想是的。不管怎样,检查一下它确实不在那里:检查你应该使用完整的会员资格提供者你是说如何检查匿名发布的产品?