英語で読む

次の方法で共有


SettingsAllowAnonymousAttribute クラス

定義

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

C#
[System.AttributeUsage(System.AttributeTargets.Property)]
public sealed class SettingsAllowAnonymousAttribute : Attribute
継承
SettingsAllowAnonymousAttribute
属性

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

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

注釈

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

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

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

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

適用対象

製品 バージョン
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

こちらもご覧ください