Set PersonalizedData on login?

Vote:
 
I have a custom login screen, containing some fields which I wish to save as PersonalizedData. However, I want to do this immediately after authenticating, which means I don't have access to the user data who has just logged in. I'm using the following code to try and access this user: string url = HandleLogin(); if (url != null) { IPrincipal principal; principal = AuthenticationProvider.Authenticate(this, Username.Text, Password.Text); HttpContext.Current.User = principal; // try and set current user in code CurrentUser.UserData["MyField"] = MyField.Text; CurrentUser.UserData.Save(); // this doesn't save PersonalizedData.Load(Username.Text); // try and populate PersonalizedData PersonalizedData.Current["MyField"] = MyField.Text; PersonalizedData.Current.Save(); // this doesn't save either Response.Redirect(url); // normal login redirect } As you can see from my comments, the two methods I've tried to set custom data for the user don't work. Can anybody help? Thanks, /\dam
#13072
Mar 25, 2008 18:35
Vote:
 
Hi Adam! The following should work: if( UnifiedPrincipal.Current.Identity.IsAuthenticated ) { PersonalizedData pd = UnifiedPrincipal.Current.UserData; pd["ShoeSize"] = "8.5"; pd["FavouritePet"] = "Cat"; pd.Save(): } Regards, Johan Olofsson
#15364
Mar 25, 2008 18:47
Vote:
 
That works a treat, many thanks! /\dam
#15365
Mar 25, 2008 18:47
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.