ProfileProviderAttributeとは? わかりやすく解説

ProfileProviderAttribute クラス

メモ : このクラスは、.NET Framework version 2.0 で新しく追加されたものです。

ユーザープロファイル プロパティのプロファイル プロバイダを識別します。

名前空間: System.Web.Profile
アセンブリ: System.Web (system.web.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.Property)> _
Public NotInheritable Class
 ProfileProviderAttribute
    Inherits Attribute
Dim instance As ProfileProviderAttribute
[AttributeUsageAttribute(AttributeTargets.Property)] 
public sealed class ProfileProviderAttribute
 : Attribute
[AttributeUsageAttribute(AttributeTargets::Property)] 
public ref class ProfileProviderAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Property) */ 
public final class ProfileProviderAttribute
 extends Attribute
AttributeUsageAttribute(AttributeTargets.Property) 
public final class ProfileProviderAttribute
 extends Attribute
解説解説

カスタム プロファイルの実装で使用するプロパティのプロファイル プロバイダを識別するには、ProfileProviderAttribute クラスが使用されます。カスタム プロファイルの実装は ProfileBase 抽象クラスから継承したクラスであり、profile 構成要素で指定されていないユーザー プロファイルのプロパティを定義します。ユーザー プロファイルのカスタム型は、次の例に示すように、アプリケーションの Web.config ファイルにある profile 構成要素の inherits 属性を使用して指定できます。

<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>

<profile inherits="Samples.AspNet.Profile.EmployeeProfile"

defaultProvider="SqlProvider">

<providers>

<clear />

<add

name="SqlProvider"

type="System.Web.Profile.SqlProfileProvider"

connectionStringName="SqlServices"

description="SQL Profile Provider for Sample"/>

<add

name="EmployeeInfoProvider"

type="System.Web.Profile.SqlProfileProvider"

connectionStringName="SqlServices"

description="SQL Profile Provider for Employee Info"/>

</providers>

<properties>

<add name="GarmentSize" />

</properties>

</profile>

</system.web>

</configuration>

使用例使用例

ProfileBase クラスから継承するクラスを定義して、カスタム プロファイルを作成するコード例を次に示します。カスタム プロファイルの型は、アプリケーションの Web.config ファイルにある profile 構成要素の inherits 属性を使用して指定します。

Imports System
Imports System.Web.Profile

Namespace Samples.AspNet.Profile

  Public Class EmployeeProfile
    Inherits ProfileBase

    <SettingsAllowAnonymous(False)> _
    <ProfileProvider("EmployeeInfoProvider")>
 _
    Public Property Department As
 String
      Get
        Return MyBase.Item("EmployeeDepartment").ToString()
      End Get
      Set
        MyBase.Item("EmployeeDepartment")
 = value
      End Set
    End Property

    <SettingsAllowAnonymous(False)> _
    <ProfileProvider("EmployeeInfoProvider")>
 _
    Public Property Details As
 EmployeeInfo
      Get
        Return CType(MyBase.Item("EmployeeInfo"),
 EmployeeInfo)
      End Get
      Set
        MyBase.Item("EmployeeInfo")
 = value
      End Set
    End Property
  End Class

  Public Class EmployeeInfo
    Public Name As String
    Public Address As String
    Public Phone As String
    Public EmergencyContactName As String
    Public EmergencyContactAddress As String
    Public EmergencyContactPhone As String
  End Class

End Namespace
using System;
using System.Web.Profile;

namespace Samples.AspNet.Profile
{
  public class EmployeeProfile : ProfileBase
  {
    [SettingsAllowAnonymous(false)]
    [ProfileProvider("EmployeeInfoProvider")]
    public string Department
    {
      get { return base["EmployeeDepartment"].ToString();
 }
      set { base["EmployeeDepartment"]
 = value; }
    }

    [SettingsAllowAnonymous(false)]
    [ProfileProvider("EmployeeInfoProvider")]
    public EmployeeInfo Details
    {
      get { return (EmployeeInfo)base["EmployeeInfo"];
 }
      set { base["EmployeeInfo"]
 = value; }
    }

  }

  public class EmployeeInfo
  {
    public string Name;
    public string Address;
    public string Phone;
    public string EmergencyContactName;
    public string EmergencyContactAddress;
    public string EmergencyContactPhone;
  }
}
.NET Framework のセキュリティ.NET Framework のセキュリティ
継承階層継承階層
System.Object
   System.Attribute
    System.Web.Profile.ProfileProviderAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ProfileProviderAttribute コンストラクタ

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

指定したプロファイル プロバイダ名を使用して ProfileProviderAttribute クラスの新しいインスタンスを作成します。

名前空間: System.Web.Profile
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Sub New ( _
    providerName As String _
)
Dim providerName As String

Dim instance As New ProfileProviderAttribute(providerName)
public ProfileProviderAttribute (
    string providerName
)
public:
ProfileProviderAttribute (
    String^ providerName
)
public ProfileProviderAttribute (
    String providerName
)
public function ProfileProviderAttribute (
    providerName : String
)

パラメータ

providerName

プロパティのプロファイル プロバイダの名前。

解説解説
使用例使用例

ProfileBase クラスから継承するクラスを定義して、カスタム プロファイルを作成するコード例を次に示します。カスタム プロファイルの型は、アプリケーションの Web.config ファイルにある profile 構成要素の inherits 属性を使用して指定します。カスタム プロファイル実装を指定する構成ファイルの例は、ProfileProviderAttribute クラスの概要を参照してください。

Imports System
Imports System.Web.Profile

Namespace Samples.AspNet.Profile

  Public Class EmployeeProfile
    Inherits ProfileBase

    <SettingsAllowAnonymous(False)> _
    <ProfileProvider("EmployeeInfoProvider")>
 _
    Public Property Department As
 String
      Get
        Return MyBase.Item("EmployeeDepartment").ToString()
      End Get
      Set
        MyBase.Item("EmployeeDepartment")
 = value
      End Set
    End Property

    <SettingsAllowAnonymous(False)> _
    <ProfileProvider("EmployeeInfoProvider")>
 _
    Public Property Details As
 EmployeeInfo
      Get
        Return CType(MyBase.Item("EmployeeInfo"),
 EmployeeInfo)
      End Get
      Set
        MyBase.Item("EmployeeInfo")
 = value
      End Set
    End Property
  End Class

  Public Class EmployeeInfo
    Public Name As String
    Public Address As String
    Public Phone As String
    Public EmergencyContactName As String
    Public EmergencyContactAddress As String
    Public EmergencyContactPhone As String
  End Class

End Namespace
using System;
using System.Web.Profile;

namespace Samples.AspNet.Profile
{
  public class EmployeeProfile : ProfileBase
  {
    [SettingsAllowAnonymous(false)]
    [ProfileProvider("EmployeeInfoProvider")]
    public string Department
    {
      get { return base["EmployeeDepartment"].ToString();
 }
      set { base["EmployeeDepartment"]
 = value; }
    }

    [SettingsAllowAnonymous(false)]
    [ProfileProvider("EmployeeInfoProvider")]
    public EmployeeInfo Details
    {
      get { return (EmployeeInfo)base["EmployeeInfo"];
 }
      set { base["EmployeeInfo"]
 = value; }
    }

  }

  public class EmployeeInfo
  {
    public string Name;
    public string Address;
    public string Phone;
    public string EmergencyContactName;
    public string EmergencyContactAddress;
    public string EmergencyContactPhone;
  }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ProfileProviderAttribute プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

ProfileProviderAttribute クラス
System.Web.Profile 名前空間

その他の技術情報

ASP.NET プロファイル プロパティ

ProfileProviderAttribute メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetHashCode  このインスタンスのハッシュ コードを返します。 ( Attribute から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 ( Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

ProfileProviderAttribute クラス
System.Web.Profile 名前空間

その他の技術情報

ASP.NET プロファイル プロパティ

ProfileProviderAttribute メンバ

ユーザープロファイル プロパティのプロファイル プロバイダを識別します。

ProfileProviderAttribute データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド ProfileProviderAttribute 指定したプロファイル プロバイダ名を使用して ProfileProviderAttribute クラスの新しいインスタンスを作成します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals  オーバーロードされます。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。)
パブリック メソッド GetHashCode  このインスタンスのハッシュ コードを返します。 (Attribute から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 (Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

ProfileProviderAttribute クラス
System.Web.Profile 名前空間

その他の技術情報

ASP.NET プロファイル プロパティ



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「ProfileProviderAttribute」の関連用語

ProfileProviderAttributeのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ProfileProviderAttributeのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS