語言

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 Global.asax 檔案中包含的事件,適用於 ASP.NET 應用程式。

以下程式碼範例展示了一個 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 Global.asax 檔案中包含的事件,用於一個 ASP.NET 應用程式。 事件會 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 目前設定檔的方法來取得匿名設定檔的屬性值。 匿名屬性值可複製至已認證使用者的當前設定檔。

建構函式

名稱 Description
ProfileMigrateEventArgs(HttpContext, String)

建立 ProfileMigrateEventArgs 類別的執行個體。

屬性

名稱 Description
AnonymousID

取得匿名檔案的匿名識別碼,從中遷移檔案的房產價值。

Context

收到目前申請的請求 HttpContext 。

方法

名稱 Description
Equals(Object)

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

(繼承來源 Object)
GetHashCode()

做為預設哈希函式。

(繼承來源 Object)
GetType()

取得目前實例的 Type。

(繼承來源 Object)
MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

適用於

另請參閱