SettingsAllowAnonymousAttribute クラス

定義

プロファイルのプロパティを設定できるかどうか、またはプロファイル プロパティに匿名ユーザーがアクセスできるかどうかを識別します。

public ref class SettingsAllowAnonymousAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Property)]
public sealed class SettingsAllowAnonymousAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Property)>]
type SettingsAllowAnonymousAttribute = class
    inherit Attribute
Public NotInheritable Class SettingsAllowAnonymousAttribute
Inherits Attribute
継承
SettingsAllowAnonymousAttribute
属性

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

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

注釈

クラスは SettingsAllowAnonymousAttribute 、ユーザーが匿名ユーザーの場合にカスタム プロファイル実装のプロパティにアクセスできるかどうかを識別するために使用されます。 匿名 ID を有効にする方法については、 anonymousIdentification 構成要素に関するドキュメントを参照してください。

プロファイル プロパティに が指定されていない SettingsAllowAnonymousAttribute 場合、プロファイル プロパティの匿名アクセスは許可されません。

カスタム プロファイル実装は、抽象クラスを ProfileBase 継承し、 プロファイル 構成要素で指定されていないユーザー プロファイルのプロパティを定義するクラスです。 次の例に示すように、アプリケーションの Web.config ファイルで、プロファイル構成要素の 属性を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>  

コンストラクター

SettingsAllowAnonymousAttribute(Boolean)

SettingsAllowAnonymousAttribute クラスの新しいインスタンスを作成して、関連付けられたプロファイル プロパティへの匿名アクセスを許可するかどうかを指定します。

プロパティ

Allow

ユーザーが匿名ユーザーである場合、そのユーザーが関連付けられたカスタム プロファイル実装のプロパティにアクセスできるかどうかを示す値を取得します。

TypeId

派生クラスで実装されると、この Attribute の一意の識別子を取得します。

(継承元 Attribute)

メソッド

Equals(Object)

このインスタンスが、指定されたオブジェクトと等価であるかどうかを示す値を返します。

(継承元 Attribute)
GetHashCode()

このインスタンスのハッシュ コードを返します。

(継承元 Attribute)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

Allow プロパティが既定値に設定されているかどうかを示す値を取得します。

Match(Object)

派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

オブジェクトの型情報を取得します。この情報はインターフェイスの型情報の取得に使用できます。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されたプロパティおよびメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象

こちらもご覧ください