Reloading the Profile object to reflect the changes

I was having trouble using the profile object. In the Logged_In event of the Login control I assign the Profile properties some new values and redirect to the new page. But on the new page it was always reading the old values.

Thanks to Fredrik I solved the problem by reloading the Profile object. Here are words of wisdom by Mr Fredrik

"

The problem is that the Profile still belongs to an anonymous user at the LoggedIn event of the Login control. The Profile feature uses an HttpModule, this module must be reloaded after a user have bean authenticated. The LoggedIn event will be trigged after a user have ban authenticated but the there is no new request to another page before that. So to solve your problem you can use the ProfileCommon's Create method and set the property of the profile class returned from the Create method. When that is done make sure to call the Save method of the profile to save the settings. Example:

            ProfileCommon p = (ProfileCommon)ProfileCommon.Create(Login1.UserName, true);

            p.FirtName = "John";
            p.LastName = "Doe";

            p.Save();

"

I will be writing an article about using the Profile object which will be hosted on www.codersource.net.

 

powered by IMHO 1.3

Print | posted @ Monday, January 02, 2006 10:30 AM

Twitter