6.1 OracleProfileProviderクラス

OracleProfileProviderにより、ASP.NET開発者は、Webサイト・ユーザー・プロファイル情報をOracleデータベースに簡単に格納できます。

クラスの継承

System.Object

  System.Configuration.Provider.ProviderBase

    System.Configuration.SettingsProvider

      System.Web.Profile.ProfileProvider

       Oracle.Web.Profile.OracleProfileProvider

宣言

// C#
public class OracleProfileProvider: ProfileProvider

スレッド安全性

すべてのパブリック静的メソッドはスレッドセーフですが、インスタンス・メンバーがスレッドセーフであることは保証されません。

備考

このクラスにより、ASP.NETアプリケーションは、Oracleデータベースにプロファイル情報を格納し、管理できます。

次に、OracleProfileProviderをデフォルト・プロバイダとして使用するASP.NETアプリケーションのweb.configファイルの例を示します。この構成では、machine.configファイルで指定された接続文字列とデフォルト属性値を使用します。プロファイルのプロパティは、プロパティ・セクションで指定されます。また、この例では、匿名IDを有効にし、匿名ユーザーにプロパティの設定を許可します。

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <system.web>
    <anonymousIdentification enabled="true"/>
    <profile enabled="true" defaultProvider="OracleProfileProvider">
      <!-- Profile properties -->
      <properties>
        <add name="hire_date" allowAnonymous="true" type="DateTime"/>
        <add name="location" allowAnonymous="true" 
                            defaultValue="Redwood Shores"/>
        <add name="experience" allowAnonymous="true" type="int"/>
      </properties>
    </profile>
  </system.web>
</configuration>

次に、OracleProfileProviderをカスタマイズされた設定およびアプリケーション固有の接続文字列とともに使用するASP.NETアプリケーションのweb.configファイルの例を示します。プロファイルのプロパティは、プロパティ・セクションで指定されます。また、この例では、匿名IDを有効にし、匿名ユーザーにプロパティの設定を許可します。

<?xml version="1.0"?>
<configuration xmlns=
  "http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <connectionStrings>
    <add name="my_profile_app_con_string" connectionString=
       "User Id=scott;Password=tiger;Data Source=Oracle"/>
  </connectionStrings>
  <system.web>
    <!-- Enable and customize OracleProfileProvider settings -->
    <anonymousIdentification enabled="true"/>
    <profile enabled="true" defaultProvider="MyOracleProfileProvider">
      <providers>
        <add name="MyOracleProfileProvider"
             type="Oracle.Web.Profile.OracleProfileProvider, 
             Oracle.Web, Version=2.112.2.0, Culture=neutral, 
             PublicKeyToken=89b483f429c47342" 
             connectionStringName="my_profile_app_con_string"
             applicationName="my_profile_app"/>
      </providers>
      <!-- Profile properties -->
      <properties>
        <add name="hire_date" allowAnonymous="true" type="DateTime"/>
        <add name="location" allowAnonymous="true" 
                  defaultValue="Redwood Shores"/>
        <add name="experience" allowAnonymous="true" type="int"/>
      </properties>
    </profile>
  </system.web>
</configuration>

applicationName属性は、ASP.NETアプリケーションごとに一意の値に設定する必要があります。

要件

ネームスペース: Oracle.Web.Profile

アセンブリ: Oracle.Web.dll

Oracle Providers for ASP.NETのバージョン: Oracle Providers for ASP.NET 2.0およびOracle Providers for ASP.NET 4