匿名和经过身份验证的配置文件可以在ASP.NET中一起共存吗? [英] Can anonymous and authenticated profiles coexist together in ASP.NET?

查看:71
本文介绍了匿名和经过身份验证的配置文件可以在ASP.NET中一起共存吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

仅通过跟踪代码,我的最佳猜测是,当它同时检测到匿名成员身份Cookie和经过身份验证的成员身份Cookie时会触发.有人可以确认吗?我在这里寻找真正的深入答案.不仅它被称为用户登录时".

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'.

现在-为什么我在乎?

在用户进行身份验证之后,我一直试图保持匿名个人资料的安全,以便他们注销后,我仍然能够知道他们是谁,以及可能已经设置的某些设置.

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.

我看到的问题是,每个请求都触发了Profile_MigrateAnonymous.不仅是用户登录时,这还是让匿名cookie随处可见的错误做法-我应该始终致电 ClearAnonymousIdentifier ();

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();

例如,我有一个新商店和一个旧商店.我希望有权访问新商店"的用户永远不要放回旧商店.显然-与大多数购物车一样,您无需启动即可开始会话.因此,我认为唯一的方法是按设计的方式调用"ClearAnonymousIdentifier",但保留辅助Cookie"UseNewStore"以跟踪他们应去的商店.

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.

这是一个很好的解释.还是我应该不在乎Profile_MigrateAnonymous一直在被调用?

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

推荐答案

不要理会它.有一种更简单的方法

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

这篇关于匿名和经过身份验证的配置文件可以在ASP.NET中一起共存吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆