我正在创建一个Asp.NET MVC-4应用程序。在我的应用中,用户可以发布他们的产品我希望无论用户是否登录[匿名],他都可以发布产品。为此我可以使用SessionId,但我担心如果会话到期我怎么能检测到匿名用户。
我想了解有关将匿名配置文件迁移到登录Userprofile的信息。请给我一些很好的教程或资源或逻辑,以便我实现这一点。
答案 0 :(得分:0)
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);
}