SettingsAllowAnonymousAttribute(Boolean) Konstruktor

Definition

Erstellt eine neue Instanz der SettingsAllowAnonymousAttribute-Klasse und gibt an, ob der anonyme Zugriff auf die zugeordnete Profileigenschaft zulässig ist.

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

Parameter

allow
Boolean

true, wenn anonyme Benutzer auf die zugeordnete Profileigenschaft zugreifen können, andernfalls false.

Beispiele

Im folgenden Beispiel wird eine Klasse definiert, die von der ProfileBase Klasse erbt, um ein benutzerdefiniertes Profil zu erstellen. Der Typ des benutzerdefinierten Profils wird im Attribut des Profilkonfigurationselements in inherits der Web.config-Datei für eine Anwendung angegeben. Ein Beispiel für eine Konfigurationsdatei, die eine benutzerdefinierte Profilimplementierung angibt, finden Sie in der SettingsAllowAnonymousAttribute Klassenübersicht.

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

Hinweise

Die SettingsAllowAnonymousAttribute Klasse wird verwendet, um zu ermitteln, ob auf eine Eigenschaft einer benutzerdefinierten Profilimplementierung zugegriffen werden kann, wenn der Benutzer ein anonymer Benutzer ist. Informationen zum Aktivieren anonymer Identifizierung finden Sie im anonymenIdentification-Konfigurationselement .

Wenn für eine Profileigenschaft kein SettingsAllowAnonymousAttribute anonymer Zugriff auf die Profileigenschaft angegeben ist, ist der anonyme Zugriff auf die Profileigenschaft nicht zulässig.

Eine benutzerdefinierte Profilimplementierung ist eine Klasse, die von der ProfileBase abstrakten Klasse erbt und Eigenschaften für das Benutzerprofil definiert, das im Profilkonfigurationselement nicht angegeben ist.

Gilt für

Siehe auch