迁移匿名配置文件的最佳方法
是否有另一种方法可以隐式迁移所有参数?或者有什么其他优点。
来自MSDN:
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);
}
或者这是最好/唯一的方法?
Is there an alternate way that migrates all parameters implicit? Or any other advantages.
From MSDN:
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);
}
Or is this the best/only way ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是要走的路。但我建议进行概括。您可以循环遍历 ProfileBase,而不是对每个属性进行硬编码.Properties 集合。沿着这些思路:
由于属性组表示为属性名称的一部分(例如“Settings.Theme”表示“设置”组中的“主题”属性),因此上述代码也应该适用于属性组。
This is the way to go. But I would suggest a generalization. Instead of hardcoding each property you could loop through the ProfileBase.Properties collection. Something along these lines:
Since property groups are represented as part of the property names (e.g. "Settings.Theme" represents the Theme property within the Settings group) the above code should also work with property groups.
我正确理解你的问题吗?
登录期间迁移配置文件属性
http://msdn.microsoft.com/en-我们/library/taab950e.aspx
Did I understand your question correctly?
Migrating Profile Properties During Log On
http://msdn.microsoft.com/en-us/library/taab950e.aspx