ProfileMigrateEventArgs 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供 MigrateAnonymous 類別之 ProfileModule 事件的資料。
public ref class ProfileMigrateEventArgs sealed : EventArgs
public sealed class ProfileMigrateEventArgs : EventArgs
type ProfileMigrateEventArgs = class
inherit EventArgs
Public NotInheritable Class ProfileMigrateEventArgs
Inherits EventArgs
- 繼承
範例
下列程式代碼範例示範可啟用匿名驗證的 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) |