SqlProfileProvider 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
管理 SQL Server 資料庫中 ASP.NET 應用程式的設定檔資訊儲存。
public ref class SqlProfileProvider : System::Web::Profile::ProfileProvider
public class SqlProfileProvider : System.Web.Profile.ProfileProvider
type SqlProfileProvider = class
inherit ProfileProvider
Public Class SqlProfileProvider
Inherits ProfileProvider
- 繼承
範例
以下程式碼範例展示了一個 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>
備註
ASP.NET 設定檔用於儲存及檢索使用者設定,儲存在資料庫等資料來源中。 使用者設定檔是利用 Profile 目前 HttpContext的屬性存取的。 房況資訊與房產價值由房況提供者管理。
ASP.NET 會用這個 SqlProfileProvider 類別來儲存和檢索使用 SQL Server 資料庫的 ASP.NET 應用程式設定檔設定。 要使用 , SqlProfileProvider您必須先建立 所使用的 SqlProfileProviderSQL Server 資料庫。 要建立 所使用的 SqlProfileProvider資料庫,請執行 aspnet_regsql.exe 工具,該工具位於 [drive:]\WINDOWS\Microsoft.NET\Framework\2.0versionNumber 資料夾中,並指定 -A p 選項 。 以下指令示範如何使用 aspnet_regsql.exe 執行檔:
aspnet_regsql.exe -A p
上述範例未指定所建立資料庫的名稱,因此會使用預設名稱。 預設資料庫名稱為 Aspnetdb。
機器設定包含一個名為 AspNetSqlProvider 的預設 SqlProfileProvider 實例,連接本地機器上的 SQL Server。 你可以使用這個提供者實例,或在 ASP.NET 應用程式的 Web.config 檔案中指定自己的。
備註
若設定檔提供者設定了使用整合安全性的連線字串,ASP.NET 應用程式的程序帳號必須擁有連接 SQL Server 資料庫的權限。
建構函式
| 名稱 | Description |
|---|---|
| SqlProfileProvider() |
建立 SqlProfileProvider 類別的執行個體。 |
屬性
| 名稱 | Description |
|---|---|
| ApplicationName |
取得或設定應用程式名稱,以儲存及檢索個人資料。 |
| Description |
獲得簡短且友善的說明,適合在管理工具或其他使用者介面(UI)中顯示。 (繼承來源 ProviderBase) |
| Name |
設定時會用友善名稱來指代供應商。 (繼承來源 ProviderBase) |