匿名和经过身份验证的配置文件可以在 ASP.NET 中共存吗?

发布于 2024-08-15 05:26:50 字数 648 浏览 5 评论 0原文

我试图弄清楚事件 Profile_MigrateAnonymous 何时触发。

通过跟踪我的代码,我的最佳猜测是,当它检测到匿名会员 cookie 和经过身份验证的会员 cookie 时,它​​就会触发。谁能证实这一点吗?我在这里寻找真正深入的答案。不仅仅是它被称为“当用户登录时”。

现在——我为什么要关心?

我试图在用户通过身份验证后保留匿名配置文件,以便一旦他们注销,我仍然能够知道他们是谁,以及可能已设置的某些设置。

我看到的问题是 Profile_MigrateAnonymous 会因每个请求而被解雇。不仅仅是当用户登录时。这让我相信保留匿名 cookie 是一种不好的做法 - 而且我应该始终调用 清除匿名标识符();

例如,我有一家新店和一家旧店。我希望有权访问“新商店”的用户永远不会回到旧商店。显然 - 与大多数购物车一样,您不需要进行身份验证即可开始会话。因此,我认为唯一的方法是按设计调用“ClearAnonymousIdentifier”,但保留辅助 cookie“UseNewStore”来跟踪他们应该去哪个商店。

这是一个很好的解释吗?或者我应该不关心 Profile_MigrateAnonymous 一直被调用?

I'm trying to figure out exactly when the event Profile_MigrateAnonymous fires.

My best guess from just tracing through my code is that it fires when it detects BOTH an anonymous membership cookie AND an authenticated membership cookie. Can anyone confirm this? I'm looking for real in depth answer here. Not just it gets called 'when a user logs in'.

Now - why do I care?

I was trying to keep the anonymous profile hanging around after a user had authenticated so that once they log out I'd still be able to tell who they were, and certain settings that may have been set.

The problem I'm seeing is that Profile_MigrateAnonymous is getting fired on EVERY request. Not just when a user has logged in. This makes me believe it to be a bad practice to keep the anonymous cookie hanging around - and that I should always call ClearAnonymousIdentifier();

For instance I have a new store and an old store. I want users that have access to the 'new store' to never be put back on the old store. Obviously - as with most shopping carts you don't need to autenticate to begin a session. Therefore I think the only way is to call 'ClearAnonymousIdentifier' as designed but keep a secondary cookie 'UseNewStore' to track which store they should go to.

is this a good interpretation. Or should I just not care that Profile_MigrateAnonymous is being called all the time?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩物 2024-08-22 05:26:50

别费心了。有一种更简单的方法可以

在登录期间迁移配置文件属性

http://msdn.microsoft .com/en-us/library/taab950e.aspx

Don't bother with it. There is a simpler way

Migrating Profile Properties During Log On

http://msdn.microsoft.com/en-us/library/taab950e.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文