Class EPiServerProfile
The base profile for users in EPiServer. Defines some basic information to implement common personalization solutions in a web site. Also contains personalization data needed for EPiServers edit mode.
Inheritance
Namespace: EPiServer.Personalization
Assembly: EPiServer.dll
Version: 7.19.2Syntax
public class EPiServerProfile : ProfileBaseExamples
Example checks if the user is authenticated and passes some Current User property values for rendering:
Example that is saving a dummy value in global scope, this information will be available on all pages for this user.
Example of greeting a user with name.
Constructors
EPiServerProfile()
Initializes a new instance of the EPiServerProfile class.
Declaration
public EPiServerProfile()Exceptions
| Type | Condition | 
|---|---|
| System.Configuration.Provider.ProviderException | The enabled attribute of the profile section of the Web.config file is false. | 
| System.Configuration.ConfigurationErrorsException | A property type specified in the profile section of the Web.config file could not be created. -or- The allowAnonymous attribute for a property in the profile section of the Web.config file is set to true and the enabled attribute of the <anonymousIdentification> element is set to false. -or- The serializeAs attribute for a property in the profile section of the Web.config file is set to System.Configuration.SettingsSerializeAs.Binary and the System.Type.IsSerializable property of the specified type returns false. -or- The name of a provider specified using the provider attribute of a profile property could not be found in the System.Web.Profile.ProfileManager.Providers collection. -or- The type specified for a profile property could not be found. -or- A profile property was specified with a name that matches a property name on the base class specified in the inherits attribute of the profile section. | 
EPiServerProfile(ProfileBase)
Initializes a new instance of the EPiServerProfile class.
Declaration
public EPiServerProfile(ProfileBase wrappedProfile)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Web.Profile.ProfileBase | wrappedProfile | The wrapped profile. | 
Properties
ClientToolsActivationKey
Typed access to the "ClientToolsActivationKey" value. Key needed for the client tools.
Declaration
public string ClientToolsActivationKey { get; set; }Property Value
| Type | Description | 
|---|---|
| System.String | The client tools activation key. | 
Company
Typed access to the "Company" value.
Declaration
public string Company { get; set; }Property Value
| Type | Description | 
|---|---|
| System.String | The company. | 
Context
Gets the associated settings context.
Declaration
public override SettingsContext Context { get; }Property Value
| Type | Description | 
|---|---|
| System.Configuration.SettingsContext | 
Country
Typed access to the "Country" value.
Declaration
public string Country { get; set; }Property Value
| Type | Description | 
|---|---|
| System.String | The country. | 
Culture
Gets or sets the users preferred UI language in the form of a System.Globalization.CultureInfo object. This is equivalent to the Language property.
Declaration
public CultureInfo Culture { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Globalization.CultureInfo | 
Current
Gets the profile for the current user.
Declaration
public static EPiServerProfile Current { get; }Property Value
| Type | Description | 
|---|---|
| EPiServerProfile | The EPiServerProfile object. | 
Remarks
Pulls the current profile from ASP.NET, but will throw exceptions if profiles are not enabled or if the profile is of the wrong type.
CustomExplorerTreePanel
Typed access to the "CustomExplorerTreePanel" value. The favorite pages for the user, displayed in the favorites tab in the page explorer.
Declaration
public string CustomExplorerTreePanel { get; set; }Property Value
| Type | Description | 
|---|---|
| System.String | The custom explorer tree panel. | 
DisplayName
Returns the user name in a format suitable for display.
Declaration
public string DisplayName { get; }Property Value
| Type | Description | 
|---|---|
| System.String | The display name of the user. | 
Remarks
If FirstName is defined, will return "FirstName LastName (UserName)", otherwise return "UserName".
EditTreeSettings
Typed access to the "EditTreeSettings" value. What icons the user wishes to see in the page tree.
Declaration
public GuiSettings EditTreeSettings { get; set; }Property Value
| Type | Description | 
|---|---|
| GuiSettings | The edit tree settings. | 
Typed access to the "email" value.
Declaration
public string Email { get; set; }Property Value
| Type | Description | 
|---|---|
| System.String | The email. | 
EmailWithMembershipFallback
Gets the email address of the current user.
Declaration
public string EmailWithMembershipFallback { get; }Property Value
| Type | Description | 
|---|---|
| System.String | The email address, or null if not defined. | 
Remarks
Will first try to get email address from the profile data. If no email address defined, attempt to load email address from the current membership provider.
Note that the membership provider might not be defined or the provider might not support email address information.
In case of error we return null and log information with error level Error.
Enabled
Gets a value indicating whether profiles are enabled and there is a current profile record.
Declaration
public static bool Enabled { get; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
Remarks
If this property returns true, then a call to EPiServerProfile.Current will not throw an exception.
FileManagerFavourites
Typed access to the "FileManagerFavourites" value. The favorite locations in the file system for the user.
Declaration
public List<string> FileManagerFavourites { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.List<System.String> | The file manager favourites. | 
FirstName
Typed access to the "FirstName" value.
Declaration
public string FirstName { get; set; }Property Value
| Type | Description | 
|---|---|
| System.String | The first name. | 
FrameworkName
Typed access to the "FrameworkName" value. Mode string for requested framework.
Declaration
public string FrameworkName { get; set; }Property Value
| Type | Description | 
|---|---|
| System.String | The name of the framework. | 
Item[String]
Gets or sets the System.Object with the specified property name.
Declaration
public override object this[string propertyName] { get; set; }Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | propertyName | 
Property Value
| Type | Description | 
|---|---|
| System.Object | 
Language
Typed access to the "Language" value. The language the user wants to see the UI in.
Declaration
public string Language { get; set; }Property Value
| Type | Description | 
|---|---|
| System.String | The language for the UI. | 
LastName
Typed access to the "LastName" value.
Declaration
public string LastName { get; set; }Property Value
| Type | Description | 
|---|---|
| System.String | The last name. | 
PropertyValues
Gets a collection of settings property values.
Declaration
public override SettingsPropertyValueCollection PropertyValues { get; }Property Value
| Type | Description | 
|---|---|
| System.Configuration.SettingsPropertyValueCollection | 
Providers
Gets a collection of settings providers.
Declaration
public override SettingsProviderCollection Providers { get; }Property Value
| Type | Description | 
|---|---|
| System.Configuration.SettingsProviderCollection | 
SubscriptionInfo
Typed access to the "SubscriptionInfo" value. The pages the user is subscribing to and the interval she wishes to get updates.
Declaration
public SubscriptionInfo SubscriptionInfo { get; set; }Property Value
| Type | Description | 
|---|---|
| SubscriptionInfo | The subscription info. | 
Title
Typed access to the "Title" value.
Declaration
public string Title { get; set; }Property Value
| Type | Description | 
|---|---|
| System.String | The title. | 
Methods
Get(String)
Gets the specified profile.
Declaration
public static EPiServerProfile Get(string username)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | username | The user name. | 
Returns
| Type | Description | 
|---|---|
| EPiServerProfile | An EPiServerProfile with profile information for the given user. | 
Remarks
This is a convenience wrapper to return a profile as an EPiServerProfile. If profiles are not configured or if the returned profile is not of the correct type, returns null. I e will not throw an exception on error.
GetProfiles(String)
Gets the profiles for the passed username.
Declaration
public static IList<EPiServerProfile> GetProfiles(string userName)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | userName | Name of the user or role | 
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IList<EPiServerProfile> | list of profiles | 
Remarks
If passed in userName is a user then the profile for that user is returned else if passed in userName represents a role profiles for all role members are returned
Save()
Updates the profile data source with changed profile property values.
Declaration
public override void Save()TryGetProfileValue(String, out Object)
Tries to get a profile value.
Declaration
public bool TryGetProfileValue(string profileProperty, out object value)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | profileProperty | The name of the profile property. | 
| System.Object | value | The value. | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | true if the value was read successfully, false otherwise. | 
Remarks
This method can be used as a convenience to handle a flexible profile with optional properties.
TrySetProfileValue(String, Object)
Tries to set a profile value.
Declaration
public bool TrySetProfileValue(string profileProperty, object value)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | profileProperty | The name of the profile property. | 
| System.Object | value | The value. | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | true if the value was set successfully, false otherwise. | 
Remarks
This method can be used as a convenience to handle a flexible profile with optional properties.
Wrap(ProfileBase)
Gets an EPiServerProfile from the ProfileBase instance.
Declaration
public static EPiServerProfile Wrap(ProfileBase profile)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Web.Profile.ProfileBase | profile | The ProfileBase instance. | 
Returns
| Type | Description | 
|---|---|
| EPiServerProfile | An EPiServerProfile instance. | 
Remarks
If the profile is already an EPiServerPrfile it is simply returned, otherwise it is wrapped in an EPiServerProfile instance.
