是否可以访问登录用户的 ASP.NET 匿名配置文件?
ASP.NET 成员资格支持匿名用户和登录用户。
如果您调用 FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
并为 createPersistentCookie
设置为 true
,那么用户在重新访问您的网站时将自动登录。网站 - 即使关闭浏览器后也是如此。如果您不启用此“记住我”功能,那么当用户再次访问您的网站时,匿名 cookie 仍将存在。
我希望能够在用户登录时将信息存储在用户的匿名个人资料中。即,如果他们离开并回来,我不希望他们在网站上保持身份验证,但我仍然希望能够跟踪某些事情 - 例如匿名配置文件中的 visitCount
属性。
有没有办法在用户经过身份验证后访问其匿名个人资料。这两个 cookie 存在,所以应该是可能的。我不想重新发明半个轮子!
附:我意识到,如果多个用户使用该系统,跟踪就会出现偏差,但这没关系。
The ASP.NET membership supports anonymous users and logged in users.
If you call FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
with a true
for createPersistentCookie
then the user will be logged in automatically when they revisit your site - even after closing the browser. If you don't enable this 'remember me' feature, then the anonymous cookie will still be around when the user visits your site again.
I'd like to do be able to store information in the user's anonymous profile when they are logged in. i.e. I don't want them to remain authenticated on the site if they go away and come back, but I'd still like be able to track certain things - like perhaps a visitCount
property in the anonymous profile.
Is there any way to access a user's anonymous profile when they are authenticated. The two cookies exist so it should be possible. I don't want to reinvent half the wheel!
ps. I realize that tracking is skewed if multiple users use the system but thats fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然。只需检查
Request
的AnonymousId
属性并构建ProfileBase
即可。Sure. Simply check the
AnonymousId
property of theRequest
and built aProfileBase
.