为用户配置文件定义一个配置文件提供程序的集合。
此元素是 .NET Framework 2.0 版中的新元素。
<providers> <add... /> <remove.../> <clear/> </providers>
下面几部分描述了属性、子元素和父元素。
无。
add
可选的元素。
向配置文件提供程序的集合添加提供程序。
clear
从配置文件提供程序的集合中移除提供程序。
remove
从集合中清除以前定义的所有配置文件提供程序。
configuration
指定公共语言运行库和 .NET Framework 应用程序所使用的每个配置文件中均需要的根元素。
system.web
为 ASP.NET 配置节指定根元素。
profile
为应用程序配置用户配置文件。
有关访问和修改应用程序代码中 profile 元素的配置值的信息,请参见 ProfileSection。
下面的默认 profile 元素在 .NET Framework 版本 2.0 的 Machine.config 文件中配置。
<providers> <add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers>
下面的代码示例演示如何配置 ASP.NET 应用程序的 Web.config 文件以使用 SqlProfileProvider 提供程序。
<configuration> <connectionStrings> <add name="SqlServices" connectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=aspnetdb;" /> </connectionStrings> <system.web> <authentication mode="Forms" > <forms loginUrl="login.aspx" name=".ASPXFORMSAUTH" /> </authentication> <authorization> <deny users="?" /> </authorization> <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15"> <providers> <clear/> <add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="SqlServices" applicationName="SampleApplication" enablePasswordRetrieval="true" enablePasswordReset="true" passwordFormat="Encrypted" requiresQuestionAndAnswer="true" /> </providers> </membership> <profile defaultProvider="SqlProvider"> <providers> <clear /> <add name="SqlProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="SqlServices" applicationName="SampleApplication" description="SqlProfileProvider for SampleApplication" /> </providers> <properties> <add name="ZipCode" /> <add name="CityAndState" /> </properties> </profile> </system.web> </configuration>
配置节处理程序
System.Web.Configuration.ProfileSection
配置成员
System.Web.Configuration.ProfileSection.Providers
可配置的位置
Machine.config
根级别的 Web.config
应用程序级别的 Web.config
要求
Microsoft Internet 信息服务 (IIS) 版本 5.0、5.1 或 6.0
.NET Framework 2.0 版
Microsoft Visual Studio 2005