ProfileModule Klasse
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Verwaltet die Erstellung des Benutzerprofils und der Profilereignisse. 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 das ProfileModule Benutzerprofil, um das Benutzerprofil zu erstellen und in der Profile Eigenschaft des aktuellen HttpContextzu speichern.
Die ProfileModule folgenden Ereignisse werden verfügbar gemacht, mit denen Sie die Authentifizierung in Ihrer Anwendung konfigurieren können:
Das MigrateAnonymous Ereignis zum Migrieren von Profileinstellungen aus einem anonymen Profil zu einem authentifizierten Profil, 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 Einstellungsschema).
Konstruktoren
| Name | Beschreibung |
|---|---|
| ProfileModule() |
Initialisiert eine neue Instanz der ProfileModule-Klasse. |
Methoden
| Name | Beschreibung |
|---|---|
| Dispose() |
Veröffentlicht alle ressourcen, die von der ProfileModule. |
| Equals(Object) |
Bestimmt, ob das angegebene Objekt dem aktuellen Objekt entspricht. (Geerbt von Object) |
| GetHashCode() |
Dient als Standardhashfunktion. (Geerbt von Object) |
| GetType() |
Ruft die Type der aktuellen Instanz ab. (Geerbt von Object) |
| Init(HttpApplication) |
Ruft Initialisierungscode auf, wenn ein ProfileModule Objekt erstellt wird. |
| MemberwiseClone() |
Erstellt eine flache Kopie der aktuellen Object. (Geerbt von Object) |
| ToString() |
Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt. (Geerbt von Object) |
Ereignisse
| Name | Beschreibung |
|---|---|
| MigrateAnonymous |
Tritt auf, wenn sich der anonyme Benutzer für ein Profil anmeldet. |
| Personalize |
Tritt auf, bevor das Benutzerprofil erstellt wird. |
| ProfileAutoSaving |
Tritt am Ende der Seitenausführung auf, wenn die automatische Profilspeicherung aktiviert ist. |