首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在mvc应用程序中处理匿名用户?

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

Stack Overflow用户
提问于 2013-08-08 14:57:19
回答 1查看 1.1K关注 0票数 0

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

我想知道如何将匿名配置文件迁移到已登录的用户配置文件。请建议我一些好的教程或资源或逻辑,我可以实现这一点。

EN

回答 1

Stack Overflow用户

发布于 2013-08-08 15:25:34

http://msdn.microsoft.com/en-us/library/ewfkf772(v=vs.100).aspx拥有一切。

使用此选项可在Global.asax中迁移rhe配置文件

代码语言:javascript
复制
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);

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18119728

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档