Redigera

Dela via


ProfileBase.Create Method

Definition

Creates an instance of a user profile.

Overloads

Create(String)

Used by ASP.NET to create an instance of a profile for the specified user name.

Create(String, Boolean)

Used by ASP.NET to create an instance of a profile for the specified user name. Takes a parameter indicating whether the user is authenticated or anonymous.

Create(String)

Used by ASP.NET to create an instance of a profile for the specified user name.

public:
 static System::Web::Profile::ProfileBase ^ Create(System::String ^ username);
public static System.Web.Profile.ProfileBase Create (string username);
static member Create : string -> System.Web.Profile.ProfileBase
Public Shared Function Create (username As String) As ProfileBase

Parameters

username
String

The name of the user to create a profile for.

Returns

An ProfileBase that represents the profile for the specified user.

Exceptions

The enabled attribute of the profile section of the Web.config file is false.

The current hosting permission level is less than Medium.

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 Binary and the 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 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.

Examples

The following code example creates an instance of a custom profile object, sets a property, and saves the profile to the data source.

MyCustomProfile myProfile = (MyCustomProfile)ProfileBase.Create("username");
myProfile.ZipCode = "98052";
myProfile.Save();
Dim myProfile As MyCustomProfile = CType(ProfileBase.Create("username"), MyCustomProfile)
myProfile.ZipCode = "98052"
myProfile.Save()

Remarks

The Create method creates and initializes a new profile instance and is useful for applications that use a custom profile object or manage user profiles in a non-ASP.NET environment.

This overload of the Create method assumes that the specified user name is an authenticated user.

See also

Applies to

Create(String, Boolean)

Used by ASP.NET to create an instance of a profile for the specified user name. Takes a parameter indicating whether the user is authenticated or anonymous.

public:
 static System::Web::Profile::ProfileBase ^ Create(System::String ^ username, bool isAuthenticated);
public static System.Web.Profile.ProfileBase Create (string username, bool isAuthenticated);
static member Create : string * bool -> System.Web.Profile.ProfileBase
Public Shared Function Create (username As String, isAuthenticated As Boolean) As ProfileBase

Parameters

username
String

The name of the user to create a profile for.

isAuthenticated
Boolean

true to indicate the user is authenticated; false to indicate the user is anonymous.

Returns

A ProfileBase object that represents the profile for the specified user.

Exceptions

The enabled attribute of the profile section of the Web.config file is false.

The current hosting permission level is less than Medium.

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 Binary and the 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 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.

Examples

The following code example creates an instance of a custom profile object, sets a property, and saves the profile to the data source.

MyCustomProfile profile = (MyCustomProfile)ProfileBase.Create("username", true);
profile.ZipCode = "98052";
profile.Save();
Dim profile As MyCustomProfile = CType(ProfileBase.Create("username", True), MyCustomProfile)
profile.ZipCode = "98052"
profile.Save()

Remarks

The Create method creates and initializes a new profile instance and is useful for applications that use a custom profile object or manage user profiles in a non-ASP.NET environment.

This overload of the Create method can be used to create a profile for an authenticated user or an anonymous user.

See also

Applies to