Aracılığıyla paylaş


ProfileModule Sınıf

Tanım

Kullanıcı profili ve profil olaylarının oluşturulmasını yönetir. Bu sınıf devralınamaz.

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
Devralma
ProfileModule
Uygulamalar

Örnekler

Aşağıdaki örnekte anonim kullanıcıları destekleyen anonim tanımlama ve profil özelliklerini etkinleştiren bir Web.config dosyası gösterilmektedir.

<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>

Aşağıdaki kod örneği, bir ASP.NET uygulamasının Global.asax dosyasına dahil edilen olayı gösterir MigrateAnonymous . Olay, MigrateAnonymous profil özelliği değerlerini anonim profilden geçerli kullanıcının profiline kopyalar.

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

Açıklamalar

Kullanıcı profili etkinleştirildiğinde, ASP.NET kullanıcı profilini oluşturmak ve geçerli HttpContextözelliğinde Profile depolamak için öğesini kullanırProfileModule.

, ProfileModule uygulamanızda kimlik doğrulamasını yapılandırmak için işleyebileceğiniz aşağıdaki olayları kullanıma sunar:

  • Anonim MigrateAnonymous bir kullanıcı oturum açtığında profil ayarlarını anonim profilden kimliği doğrulanmış bir profile geçirmek için olay.

  • Olay Personalize , kullanıcı profilinin oluşturulma şeklini özelleştirmek için.

  • Özellik ProfileAutoSaving olarak ayarlandığında kullanıcı profilinin nasıl kaydedileceğini AutomaticSaveEnabled denetlemek için trueolayı.

Kullanıcı profilini etkinleştirme hakkında bilgi için bkz. profil Öğesi (ASP.NET Ayarlar Şeması).

Oluşturucular

Name Description
ProfileModule()

ProfileModule sınıfının yeni bir örneğini başlatır.

Yöntemler

Name Description
Dispose()

tarafından ProfileModulekullanılan tüm kaynakları serbest bırakır.

Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Geçerli örneğin Type alır.

(Devralındığı yer: Object)
Init(HttpApplication)

Bir ProfileModule nesne oluşturulduğunda başlatma kodunu çağırır.

MemberwiseClone()

Geçerli Objectbasit bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden bir dize döndürür.

(Devralındığı yer: Object)

Ekinlikler

Name Description
MigrateAnonymous

Profil için anonim kullanıcı oturum açtığında gerçekleşir.

Personalize

Kullanıcı profili oluşturulmadan önce gerçekleşir.

ProfileAutoSaving

Otomatik profil kaydetme etkinse, sayfa yürütmenin sonunda gerçekleşir.

Şunlara uygulanır

Ayrıca bkz.