用户配置文件对象为空,即使用户正确登录?
我使用 asp:Login 控件,用户可以正常登录,但是在登录控件的 LoggedIn 事件中检查用户配置文件信息时,Profile 对象中的所有字段都是空的。 此外,User.Identity.IsAuthenticated 始终返回 false。
但是,所有这些问题在导航到另一个页面时都得到了解决。
即使用户正确登录,为什么 User.Identity.IsAuthenticated 返回 false? 并且,有什么方法可以在登录控件的 LoggedIn 事件中获取用户的个人资料信息吗?
I use asp:Login control, user can login properly, but while checking user Profile information within LoggedIn event of Login control, all of the fields in the Profile objects are empty.
Also, User.Identity.IsAuthenticated always returns false.
But, all of these issue solved while navigating to another page.
Why User.Identity.IsAuthenticated returns false, even user logged-in properly?
And, is there any way to get user's profile information within LoggedIn event of Login control?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
登录后,表单必须重定向到下一页以填充用户主体信息(页面/上下文的用户属性)。这就是为什么提到使用控件的用户名。
可以等到重定向之后吗?您需要直接访问吗?
Login1.UserName
应该可以工作;在那里放置一个调试器并确保填充该值。您还可以尝试:
HttpContext.Current.Profile.GetProfile( ... )
After logging in, the form must redirect to the next page to populate the User principal information (User property of page/context). So that is why it was mentioned to use the UserName of the control.
Can you wait until after the redirect? Do you need direct access?
Login1.UserName
should work; put a debugger there and make sure the value is populated.You could also try:
HttpContext.Current.Profile.GetProfile( ... )
在 LoggedIn 事件中,用户和配置文件身份尚未更新。请尝试以下操作:
要访问用户:
要访问配置文件:
(Login1 是您的登录控件。)
In the LoggedIn event the User and Profile identities are not yet updated. Try instead this:
To access the user:
To access the profile:
(Login1 is your Login control.)