Share via


設定檔的 providers 項目 (ASP.NET 設定結構描述)

為使用者設定檔定義設定檔提供者的集合。

這個項目是 .NET Framework 2.0 版中新增的項目。

<providers>
    <add... />
    <remove.../>
    <clear/>
</providers>

屬性和項目

下列章節會說明屬性、子項目和父項目。

屬性

無。

子項目

項目

描述

add

選擇性項目。

將提供者加入設定檔提供者的集合。

clear

選擇性項目。

移除設定檔提供者集合中的提供者。

remove

選擇性項目。

清除集合中之所有先前定義的設定檔提供者。

父項目

項目

描述

configuration

指定 Common Language Runtime 和 .NET Framework 應用程式所使用之每個組態檔中需要的根項目 (Root Element)。

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

組態成員

ProfileSection.Providers

可設定的位置

Machine.config

根層次的 Web.config

應用程式層級的 Web.config

需求

Microsoft Internet Information Services (IIS) 5.0、5.1 或 6.0 版

.NET Framework 2.0 版

Microsoft Visual Studio 2005

請參閱

工作

How to: Lock ASP.NET Configuration Settings

參考

profile 項目 (ASP.NET 設定結構描述)

system.web 項目 (ASP.NET 設定結構描述)

<configuration> 項目

設定檔提供者的 add 項目 (ASP.NET 設定結構描述)

設定檔提供者的 remove 項目 (ASP.NET 設定結構描述)

設定檔提供者的 clear 項目 (ASP.NET 設定結構描述)

ProfileSection

System.Configuration

System.Web.Configuration

概念

ASP.NET Profile Properties Overview

ASP.NET Configuration Overview

ASP.NET Server Controls and Browser Capabilities

Securing Configuration

Configuration Inheritance

其他資源

ASP.NET Configuration Files

ASP.NET 組態設定

一般組態設定 (ASP.NET)

ASP.NET Configuration API