用户配置文件对象为空,即使用户正确登录?

发布于 2024-08-27 06:03:46 字数 272 浏览 6 评论 0原文

我使用 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 技术交流群。

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

发布评论

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

评论(2

幽梦紫曦~ 2024-09-03 06:03:46

登录后,表单必须重定向到下一页以填充用户主体信息(页面/上下文的用户属性)。这就是为什么提到使用控件的用户名。

可以等到重定向之后吗?您需要直接访问吗? 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( ... )

浅语花开 2024-09-03 06:03:46

在 LoggedIn 事件中,用户和配置文件身份尚未更新。请尝试以下操作:

要访问用户:

MembershipUser aUser = Membership.GetUser(Login1.UserName);
// work with aUser ...

要访问配置文件:

ProfileCommon aProfile = Profile.GetProfile(Login1.UserName);
// work with the member fields in aProfile ...

(Login1 是您的登录控件。)

In the LoggedIn event the User and Profile identities are not yet updated. Try instead this:

To access the user:

MembershipUser aUser = Membership.GetUser(Login1.UserName);
// work with aUser ...

To access the profile:

ProfileCommon aProfile = Profile.GetProfile(Login1.UserName);
// work with the member fields in aProfile ...

(Login1 is your Login control.)

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