asp.net – 迁移匿名配置文件的最佳方式
发布时间:2020-05-24 11:09:55 所属栏目:asp.Net 来源:互联网
导读:是否有另一种方法可以隐式迁移所有参数?或任何其他优点. 从MSDN开始: public void Profile_OnMigrateAnonymous(object sender, ProfileMigrateEventArgs args){ ProfileCommon anonymousProfile = Profile.GetProfile(args.AnonymousID); P
|
是否有另一种方法可以隐式迁移所有参数?或任何其他优点. 从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);
}
或者这是最好/唯一的方式? 解决方法这是要走的路.但我建议进行推广.您可以循环访问 ProfileBase.Properties集合,而不是对每个属性进行硬编码.这些方面的东西:var anonymousProfile = Profile.GetProfile(args.AnonymousID);
foreach(var property in anonymousProfile.PropertyValues)
{
Profile.SetPropertyValue(property.Name,property.PropertyValue);
}
由于属性组表示为属性名称的一部分(例如“Settings.Theme”表示“设置”组中的“主题”属性),因此上述代码也应与属性组一起使用. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- ASP.NET Core使用SkiaSharp实现验证码的示例代码
- 将列表绑定到asp.net 3.5中的列表视图
- asp.net – 如何在网格行中显示枚举描述或名称?
- asp.net-mvc – MVC 5具有身份验证模式的外部身份验证=表单
- asp.net – 刷新网页会怎么样?
- asp.net-mvc – 最新的ASP.Net MVC 3请求处理管道图?
- asp.net-mvc – 如何使用ASP.NET MVC的plupload包?
- asp.net-mvc – ASP.NET MVC 2中的空查询字符串参数的模型绑
- 决定Umbraco和Orchard之间ASP.NET CMS
- asp.net-mvc-3 – MVC-Mini-Profiler错误地显示重复的查询
推荐文章
站长推荐
- ASP.NET Webforms ASP.NET Ajax与ASP.NET MVC和A
- asp.net-mvc – 所有ASP.NET Web API控制器返回4
- asp.net-mvc-2 – MVC源代码单例模式
- asp.net-mvc – 属性路由和本地化问题
- C# 快速高效率复制对象另一种方式 表达式树
- 写单元测试在ASP.NET Web API中使用User.Identit
- asp.net-mvc – ModelState.AddModelError未显示
- ASP.NET和底层连接已关闭:无法为SSL / TLS安全通
- 实体框架 – 使用实体框架数据模型添加验证属性
- asp.net – 为什么GET方法比POST快?
热点阅读
