开发者

User Profile objects are empty, even user logged-in properly?

开发者 https://www.devze.com 2022-12-25 15:28 出处:网络
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.

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 an开发者_运维百科other 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?


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消