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向 类的 ProfileModule 事件提供事件信息MigrateAnonymous。 对象 ProfileMigrateEventArgs 提供对 HttpContext 当前请求的访问,以及 属性中 AnonymousID 匿名配置文件的匿名用户标识符。

当匿名使用应用程序的用户登录时, MigrateAnonymous 可以使用 事件将配置文件属性值从匿名配置文件复制到经过身份验证的配置文件。

启动启用了用户配置文件的应用程序时,ASP.NET 会创建继承自 ProfileBase 类的 类型ProfileCommon的新类。 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)

适用于

另请参阅