ProfileMigrateEventArgs 類別

定義

提供 MigrateAnonymous 類別之 ProfileModule 事件的資料。

public ref class ProfileMigrateEventArgs sealed : EventArgs
public sealed class ProfileMigrateEventArgs : EventArgs
type ProfileMigrateEventArgs = class
    inherit EventArgs
Public NotInheritable Class ProfileMigrateEventArgs
Inherits EventArgs
繼承
ProfileMigrateEventArgs

範例

下列程式碼範例示範可啟用匿名驗證的Web.config檔案,以及 MigrateAnonymous ASP.NET 應用程式之 Global.asax 檔案中包含的事件。

下列程式碼範例示範Web.config檔案,可啟用支援匿名使用者的匿名識別和配置檔案屬性。

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

下列程式碼範例顯示 MigrateAnonymous ASP.NET 應用程式之 Global.asax 檔案中包含的事件。 事件會將 MigrateAnonymous 配置檔案屬性值從匿名配置檔案複製到目前使用者的設定檔。

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

備註

物件 ProfileMigrateEventArgs 會將事件資訊提供給 MigrateAnonymous 類別的事件 ProfileModule 。 物件 ProfileMigrateEventArgs 提供目前要求的 存取 HttpContext 權,以及 屬性中匿名設定檔的 AnonymousID 匿名使用者識別碼。

當使用應用程式登入的使用者已匿名登入時,您可以使用 MigrateAnonymous 事件,將配置檔案屬性值從匿名配置檔案複製到已驗證的設定檔。

啟動已啟用使用者設定檔的應用程式時,ASP.NET 會建立 類型的新類別 ProfileCommon ,其繼承自 ProfileBase 類別。 ProfileCommon產生 類別時,會根據Web.config檔案中指定的配置檔案屬性, GetProfile 新增方法可讓您根據使用者名稱擷取 ProfileCommon 物件。 您可以使用 GetProfile 目前設定檔的 方法來擷取匿名設定檔的屬性值。 然後,匿名屬性值可以複製到已驗證使用者的目前設定檔。

建構函式

ProfileMigrateEventArgs(HttpContext, String)

建立 ProfileMigrateEventArgs 類別的執行個體。

屬性

AnonymousID

取得匿名設定檔的匿名識別項,以從該設定檔移轉設定檔屬性值。

Context

取得目前要求的 HttpContext

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱