ProfileBase.ProfileBase Constructor
Assembly: System.Web (in system.web.dll)
| Exception type | Condition |
|---|---|
|
The enabled attribute of the profile section of the Web.config file is false. | |
|
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. |
ASP.NET uses the ProfileBase class to create the class used for the user profile. When an application that has the user profile enabled is started, ASP.NET creates a new class of type ProfileCommon, which inherits from the ProfileBase class. Strongly typed accessors are added to the ProfileCommon class for each property defined in the profile configuration section. The strongly typed accessors of the ProfileCommon class call the GetPropertyValue and SetPropertyValue methods of the ProfileBase base class to retrieve and set profile property values, respectively. An instance of the ProfileCommon class is set as the value of the Profile property for the ASP.NET application.
Note: |
|---|
|
The base class used to generate the class stored in the Profile property can be overridden using the inherits attribute of the profile section of the configuration file. In this case you would specify a custom class that inherits from the ProfileBase base class. |
This constructor is not intended to be used from application code. To create an instance of a user profile, use the Create method.
The following Web.config file specifies a user profile that contains a ZipCode property of type string and a RecentSearchList property of type StringCollection. The generated Profile property of the current HttpContext will have strongly typed accessors for each of the specified properties.
<configuration>
<connectionStrings>
<add name="SqlServices" connectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=aspnetdb;" />
</connectionStrings>
<system.web>
<anonymousIdentification enabled="true" />
<profile defaultProvider="SqlProvider" >
<providers>
<add
name="SqlProvider"
connectionStringName="SqlServices"
applicationName="ProfileBaseApplication"
type="System.Web.Profile.SqlProfileProvider" />
</providers>
<properties>
<add name="ZipCode" allowAnonymous="true" />
<add name="RecentSearchList"
type="System.Collections.Specialized.StringCollection"
serializeAs="Xml"
allowAnonymous="true" />
</properties>
</profile>
</system.web>
</configuration>
The following ASP.NET page reads and sets the ZipCode property specified for the user profile.
Security Note: |
|---|
|
This example contains a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview (Visual Studio). |
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.
Note: