注意:此类在 .NET Framework 2.0 版中是新增的。
管理用户配置文件和配置文件事件的创建。无法继承此类。
命名空间:System.Web.Profile
程序集:System.Web(在 system.web.dll 中)
Public NotInheritable Class ProfileModule
Implements IHttpModule
Dim instance As ProfileModule
public sealed class ProfileModule : IHttpModule
public ref class ProfileModule sealed : IHttpModule
public final class ProfileModule implements IHttpModule
public final class ProfileModule implements IHttpModule
当启用用户配置文件时,ASP.NET 使用 ProfileModule 来创建用户配置文件,并将其存储在当前 HttpContext 的 Profile 属性中。
ProfileModule 公开下面的事件,您可以处理这些事件以在应用程序中配置身份验证:
有关启用用户配置文件的信息,请参见 profile 元素(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>
下面的代码示例演示 ASP.NET 应用程序的 Global.asax 文件中包含的 MigrateAnonymous 事件。MigrateAnonymous 事件将配置文件属性值从匿名配置文件复制到当前用户的配置文件。
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()
End Sub
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();
}
System.Object
System.Web.Profile.ProfileModule
此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。
Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
.NET Framework
受以下版本支持:2.0