ProfileModule Klasse

Definition

Verwaltet die Erstellung des Benutzerprofils und von Profilereignissen. Diese Klasse kann nicht vererbt werden.

public ref class ProfileModule sealed : System::Web::IHttpModule
public sealed class ProfileModule : System.Web.IHttpModule
type ProfileModule = class
    interface IHttpModule
Public NotInheritable Class ProfileModule
Implements IHttpModule
Vererbung
ProfileModule
Implementiert

Beispiele

Das folgende Beispiel zeigt eine Web.config-Datei, die anonyme Identifikations- und Profileigenschaften ermöglicht, die anonyme Benutzer unterstützen.

<configuration>  
  <system.web>  
    <authentication mode="Forms" >  
      <forms loginUrl="login.aspx" name=".ASPXFORMSAUTH" />  
    </authentication>  

    <anonymousIdentification enabled="true" />  

    <profile enabled="true" defaultProvider="AspNetSqlProvider">  
      <properties>  
        <add name="ZipCode" allowAnonymous="true" />  
        <add name="CityAndState" allowAnonymous="true" />  
        <add name="StockSymbols" type="System.Collections.ArrayList" allowAnonymous="true" />  
      </properties>  
    </profile>  
  </system.web>  
</configuration>  

Das folgende Codebeispiel zeigt das Ereignis, das MigrateAnonymous in der Datei Global.asax für eine ASP.NET-Anwendung enthalten ist. Das MigrateAnonymous Ereignis kopiert Profileigenschaftenwerte aus dem anonymen Profil in das Profil für den aktuellen Benutzer.

public void Profile_OnMigrateAnonymous(object sender, ProfileMigrateEventArgs args)
{
  ProfileCommon anonymousProfile = Profile.GetProfile(args.AnonymousID);

  Profile.ZipCode = anonymousProfile.ZipCode;
  Profile.CityAndState = anonymousProfile.CityAndState;
  Profile.StockSymbols = anonymousProfile.StockSymbols;

  ////////
  // Delete the anonymous profile. If the anonymous ID is not 
  // needed in the rest of the site, remove the anonymous cookie.

  ProfileManager.DeleteProfile(args.AnonymousID);
  AnonymousIdentificationModule.ClearAnonymousIdentifier(); 

  // Delete the user row that was created for the anonymous user.
  Membership.DeleteUser(args.AnonymousID, true);

}
Public Sub Profile_OnMigrateAnonymous(sender As Object, args As ProfileMigrateEventArgs)
  Dim anonymousProfile As ProfileCommon = Profile.GetProfile(args.AnonymousID)

  Profile.ZipCode = anonymousProfile.ZipCode
  Profile.CityAndState = anonymousProfile.CityAndState
  Profile.StockSymbols = anonymousProfile.StockSymbols

  ''''''''
  ' Delete the anonymous profile. If the anonymous ID is not 
  ' needed in the rest of the site, remove the anonymous cookie.

  ProfileManager.DeleteProfile(args.AnonymousID)
  AnonymousIdentificationModule.ClearAnonymousIdentifier()

  ' Delete the user row that was created for the anonymous user.
  Membership.DeleteUser(args.AnonymousID, True)
End Sub

Hinweise

Wenn das Benutzerprofil aktiviert ist, verwendet ASP.NET, ProfileModule um das Benutzerprofil zu erstellen und in der Profile -Eigenschaft des aktuellen HttpContextzu speichern.

Macht ProfileModule die folgenden Ereignisse verfügbar, die Sie behandeln können, um die Authentifizierung in Ihrer Anwendung zu konfigurieren:

  • Das MigrateAnonymous -Ereignis, um Profileinstellungen von einem anonymen Profil zu einem authentifizierten Profil zu migrieren, wenn sich ein anonymer Benutzer anmeldet.

  • Das Personalize -Ereignis, um anzupassen, wie das Benutzerprofil erstellt wird.

  • Das ProfileAutoSaving -Ereignis, um zu steuern, wie das Benutzerprofil gespeichert wird, wenn die AutomaticSaveEnabled -Eigenschaft auf truefestgelegt ist.

Informationen zum Aktivieren des Benutzerprofils finden Sie unter profile Element (ASP.NET Settings Schema).

Konstruktoren

ProfileModule()

Initialisiert eine neue Instanz der ProfileModule-Klasse.

Methoden

Dispose()

Gibt alle vom ProfileModule verwendeten Ressourcen frei.

Equals(Object)

Bestimmt, ob das angegebene Objekt gleich dem aktuellen Objekt ist.

(Geerbt von Object)
GetHashCode()

Fungiert als Standardhashfunktion.

(Geerbt von Object)
GetType()

Ruft den Type der aktuellen Instanz ab.

(Geerbt von Object)
Init(HttpApplication)

Ruft den Initialisierungscode auf, wenn ein ProfileModule-Objekt erstellt wird.

MemberwiseClone()

Erstellt eine flache Kopie des aktuellen Object.

(Geerbt von Object)
ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.

(Geerbt von Object)

Ereignisse

MigrateAnonymous

Tritt auf, wenn sich der anonyme Benutzer für ein Profil anmeldet.

Personalize

Tritt auf, bevor das Benutzerprofil erstellt wird.

ProfileAutoSaving

Tritt am Schluss der Seitenausführung auf, wenn das automatische Speichern von Profilen aktiviert ist.

Gilt für:

Weitere Informationen