是否有另一种方法可以隐式迁移所有参数?或者有什么其他优点。
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);
}
或者这是最好/唯一的方法?
这是要走的路。但我建议进行概括。您可以循环遍历每个属性,而不是硬编码配置文件库.属性收藏。沿着这些思路:
var anonymousProfile = Profile.GetProfile(args.AnonymousID);
foreach(var property in anonymousProfile.PropertyValues)
{
Profile.SetPropertyValue(property.Name, property.PropertyValue);
}
由于属性组表示为属性名称的一部分(例如“Settings.Theme”表示“设置”组中的“主题”属性),因此上述代码也应适用于属性组。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)