SettingsAllowAnonymousAttribute(Boolean) 생성자

정의

클래스의 새 인스턴스를 SettingsAllowAnonymousAttribute 만들고 연결된 프로필 속성에 대한 익명 액세스를 허용할지 여부를 지정합니다.

public:
 SettingsAllowAnonymousAttribute(bool allow);
public SettingsAllowAnonymousAttribute(bool allow);
new System.Web.Profile.SettingsAllowAnonymousAttribute : bool -> System.Web.Profile.SettingsAllowAnonymousAttribute
Public Sub New (allow As Boolean)

매개 변수

allow
Boolean

true 익명 사용자가 연결된 프로필 속성에 액세스할 수 있으면 이고, 그렇지 않으면 false.

예제

다음 예제에서는 사용자 지정 프로필을 만들기 위해 클래스에서 ProfileBase 상속되는 클래스를 정의합니다. 사용자 지정 프로필의 형식은 애플리케이션에 inherits 대한 Web.config 파일의 프로필 구성 요소 특성에 지정됩니다. 사용자 지정 프로필 구현을 지정하는 구성 파일의 예제는 클래스 개요를 SettingsAllowAnonymousAttribute 참조하세요.

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 상속되고 프로필 구성 요소에 지정되지 않은 사용자 프로필의 속성을 정의하는 클래스입니다.

적용 대상

추가 정보