Share via


How to Refresh a Profile Instance

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

If you have a single Commerce Server Web server, you can update a profile automatically in your site code or by using the Profiles Web service. However, if you have multiple servers in a Web farm or if an external system updates a profile, you will have to refresh the instance of the profile.

You may also need to refresh a profile when an offline application, such as a Customer Service application, modifies user data and must reflect the change in Commerce Server.

Note

Profile changes will not be available to other servers in a Web farm until the profile is refreshed in code or the profiles cache is refreshed automatically because of cache time-out. This delay can cause problems if you disable a user and the change is not reflected immediately in all servers. One way to avoid this problem is to create a blocked users table that stores user IDs who should be denied access to Commerce Server, and to have your logon code check this table before giving a user access to Commerce Server.

If you are using a Web farm, updating a single Web server will cause the profile data in the other servers to become out of sync. Therefore, you must call the Refresh method on each Web server in your farm to make sure that each Web server is current.

If you must update only a single profile, all Web servers in your Web farm can be updated by calling the RefreshProfileCache method of the ProfileManagementContext object. If your offline application must update all profiles on all Web servers in your Web farm, you can call the RefreshProfileCache method of the ProfileManagementContext object (passing no parameters).

Warning

Do not refresh a profile instance unless the application requires it. This operation can be resource-intensive. Also, do not perform bulk updates frequently or during peak hours, as these operations can affect server performance.

To refresh a profile instance

  1. Create an instance of a ProfileContext object.

  2. Retrieve an instance of a profile.

  3. Call the Refresh method of the ProfileContext object.

Example

// Get the Profiles run-time object.
ProfileContext ctxt = CommerceContext.Current.ProfileSystem;

// Get the profile from an eMail variable.
Profile prof = ctxt.GetProfile("email_address", eMail, "UserObject");

// Refresh the profile.
prof.Refresh();

See Also

Other Resources

Profiles Concepts and Tasks

Developing with the Profiles System