/
ProfileMigrateEventHandler.xml
73 lines (60 loc) · 4.95 KB
/
ProfileMigrateEventHandler.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<Type Name="ProfileMigrateEventHandler" FullName="System.Web.Profile.ProfileMigrateEventHandler">
<TypeSignature Language="C#" Value="public delegate void ProfileMigrateEventHandler(object sender, ProfileMigrateEventArgs e);" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed ProfileMigrateEventHandler extends System.MulticastDelegate" />
<TypeSignature Language="DocId" Value="T:System.Web.Profile.ProfileMigrateEventHandler" />
<TypeSignature Language="VB.NET" Value="Public Delegate Sub ProfileMigrateEventHandler(sender As Object, e As ProfileMigrateEventArgs)" />
<TypeSignature Language="F#" Value="type ProfileMigrateEventHandler = delegate of obj * ProfileMigrateEventArgs -> unit" />
<TypeSignature Language="C++ CLI" Value="public delegate void ProfileMigrateEventHandler(System::Object ^ sender, ProfileMigrateEventArgs ^ e);" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Delegate</BaseTypeName>
</Base>
<Parameters>
<Parameter Name="sender" Type="System.Object" />
<Parameter Name="e" Type="System.Web.Profile.ProfileMigrateEventArgs" />
</Parameters>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Docs>
<param name="sender">The <see cref="T:System.Web.Profile.ProfileModule" /> that raised the <see cref="E:System.Web.Profile.ProfileModule.MigrateAnonymous" /> event.</param>
<param name="e">A <see cref="T:System.Web.Profile.ProfileMigrateEventArgs" /> that contains the event data.</param>
<summary>Represents the method that will handle the <see cref="E:System.Web.Profile.ProfileModule.MigrateAnonymous" /> event of the <see cref="T:System.Web.Profile.ProfileModule" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.Profile.ProfileMigrateEventHandler> delegate is defined for the <xref:System.Web.Profile.ProfileModule.MigrateAnonymous> event of the <xref:System.Web.Profile.ProfileModule> class. You can access the <xref:System.Web.Profile.ProfileModule.MigrateAnonymous> event of the <xref:System.Web.Profile.ProfileModule> class in the Global.asax file for your ASP.NET application as shown in the example for this topic.
You can use the <xref:System.Web.Profile.ProfileModule.MigrateAnonymous> event to copy profile property values from an anonymous profile to an authenticated profile when someone who has been anonymously using your application logs in.
When an application that has the user profile enabled is started, ASP.NET creates a new class of type `ProfileCommon`, which inherits from the <xref:System.Web.Profile.ProfileBase> class. When the `ProfileCommon` class is generated, based on the profile properties specified in the Web.config file, a `GetProfile` method is added that enables you to retrieve a `ProfileCommon` object based on a user name. You can use the `GetProfile` method of the current profile to retrieve the property values of the anonymous profile. The anonymous property values can then be copied to the current profile for the authenticated user.
## Examples
The following code examples show a Web.config file that enables anonymous authentication and the <xref:System.Web.Profile.ProfileModule.MigrateAnonymous> event included in the Global.asax file for an ASP.NET application.
The following code example shows a Web.config file that enables anonymous identification and profile properties that support anonymous users.
```
<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>
```
The following code example shows the <xref:System.Web.Profile.ProfileModule.MigrateAnonymous> event included in the Global.asax file for an ASP.NET application. The <xref:System.Web.Profile.ProfileModule.MigrateAnonymous> event copies profile property values from the anonymous profile to the profile for the current user.
[!code-csharp[System.Web.Profile.ProfileManager#1](~/snippets/csharp/VS_Snippets_WebNet/System.Web.Profile.ProfileManager/CS/global.asax#1)]
[!code-vb[System.Web.Profile.ProfileManager#1](~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Profile.ProfileManager/VB/global.asax#1)]
]]></format>
</remarks>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/2y3fs9xs(v=vs.100)">ASP.NET Profile Properties Overview</related>
</Docs>
</Type>