SettingsAllowAnonymousAttribute クラス
アセンブリ: System.Web (system.web.dll 内)

<AttributeUsageAttribute(AttributeTargets.Property)> _ Public NotInheritable Class SettingsAllowAnonymousAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Property)] public sealed class SettingsAllowAnonymousAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Property)] public ref class SettingsAllowAnonymousAttribute sealed : public Attribute

ユーザーが匿名ユーザーである場合、そのユーザーがカスタム プロファイル実装のプロパティにアクセスできるかどうかを識別するには、SettingsAllowAnonymousAttribute クラスが使用されます。匿名ユーザーの識別を有効にする方法については、anonymousIdentification 構成要素についてのドキュメントを参照してください。
プロファイル プロパティに対して SettingsAllowAnonymousAttribute が指定されていない場合、そのプロファイル プロパティへの匿名アクセスは許可されません。
カスタム プロファイルの実装は ProfileBase 抽象クラスから継承したクラスであり、profile 構成要素で指定されていないユーザー プロファイルのプロパティを定義します。アプリケーションの Web.config ファイルにあるカスタム ユーザー プロファイルの型は、次の例に示すように、profile 構成要素の inherits 属性を使用して指定できます。
<connectionStrings>
<add
name="SqlServices"
connectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=aspnetdb;" />
</connectionStrings>
<authentication mode="Forms" >
loginUrl="login.aspx"
name=".ASPXFORMSAUTH" />
</authentication>
</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>
</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; } }


System.Attribute
System.Web.Profile.SettingsAllowAnonymousAttribute


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- SettingsAllowAnonymousAttribute クラスのページへのリンク