/
ProfileModule.xml
324 lines (274 loc) · 21.8 KB
/
ProfileModule.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
<Type Name="ProfileModule" FullName="System.Web.Profile.ProfileModule">
<TypeSignature Language="C#" Value="public sealed class ProfileModule : System.Web.IHttpModule" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit ProfileModule extends System.Object implements class System.Web.IHttpModule" />
<TypeSignature Language="DocId" Value="T:System.Web.Profile.ProfileModule" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class ProfileModule
Implements IHttpModule" />
<TypeSignature Language="F#" Value="type ProfileModule = class
 interface IHttpModule" />
<TypeSignature Language="C++ CLI" Value="public ref class ProfileModule sealed : System::Web::IHttpModule" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces>
<Interface>
<InterfaceName>System.Web.IHttpModule</InterfaceName>
</Interface>
</Interfaces>
<Docs>
<summary>Manages the creation of the user profile and profile events. This class cannot be inherited.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When the user profile is enabled, ASP.NET uses the <xref:System.Web.Profile.ProfileModule> to create the user profile and store it in the <xref:System.Web.HttpContext.Profile%2A> property of the current <xref:System.Web.HttpContext>.
The <xref:System.Web.Profile.ProfileModule> exposes the following events you can handle to configure authentication in your application:
- The <xref:System.Web.Profile.ProfileModule.MigrateAnonymous> event, to migrate profile settings from an anonymous profile to an authenticated profile when an anonymous user logs in.
- The <xref:System.Web.Profile.ProfileModule.Personalize> event, to customize how the user profile is created.
- The <xref:System.Web.Profile.ProfileModule.ProfileAutoSaving> event, to control how the user profile is saved when the <xref:System.Web.Profile.ProfileManager.AutomaticSaveEnabled%2A> property is set to `true`.
For information about enabling the user profile, see [profile Element (ASP.NET Settings Schema)](https://msdn.microsoft.com/library/ccb9bf3a-a044-464d-b89b-5cb5a3d389dd).
## Examples
The following 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>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ProfileModule ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Profile.ProfileModule.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:
 ProfileModule();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Web.Profile.ProfileModule" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This constructor is not intended to be called from application code.
An <xref:System.Web.HttpApplication> is created when an ASP.NET application is started. The <xref:System.Web.HttpApplication> calls the <xref:System.Web.Profile.ProfileModule> constructor to create the <xref:System.Web.Profile.ProfileModule> for the application. The <xref:System.Web.Profile.ProfileModule> is specified in the configuration for an application.
]]></format>
</remarks>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/2y3fs9xs(v=vs.100)">ASP.NET Profile Properties Overview</related>
</Docs>
</Member>
<Member MemberName="Dispose">
<MemberSignature Language="C#" Value="public void Dispose ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void Dispose() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Profile.ProfileModule.Dispose" />
<MemberSignature Language="VB.NET" Value="Public Sub Dispose ()" />
<MemberSignature Language="F#" Value="abstract member Dispose : unit -> unit
override this.Dispose : unit -> unit" Usage="profileModule.Dispose " />
<MemberSignature Language="C++ CLI" Value="public:
 virtual void Dispose();" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Web.IHttpModule.Dispose</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Releases all resources used by the <see cref="T:System.Web.Profile.ProfileModule" />.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method is not intended to be called from application code.
An <xref:System.Web.HttpApplication> is created when an ASP.NET application is started. The <xref:System.Web.HttpApplication> creates and initializes the <xref:System.Web.Profile.ProfileModule> for the application and calls the <xref:System.Web.Profile.ProfileModule.Dispose%2A> method when the object is released. The <xref:System.Web.Profile.ProfileModule> is specified in the configuration for an application.
]]></format>
</remarks>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/2y3fs9xs(v=vs.100)">ASP.NET Profile Properties Overview</related>
</Docs>
</Member>
<Member MemberName="Init">
<MemberSignature Language="C#" Value="public void Init (System.Web.HttpApplication app);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void Init(class System.Web.HttpApplication app) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Profile.ProfileModule.Init(System.Web.HttpApplication)" />
<MemberSignature Language="VB.NET" Value="Public Sub Init (app As HttpApplication)" />
<MemberSignature Language="F#" Value="abstract member Init : System.Web.HttpApplication -> unit
override this.Init : System.Web.HttpApplication -> unit" Usage="profileModule.Init app" />
<MemberSignature Language="C++ CLI" Value="public:
 virtual void Init(System::Web::HttpApplication ^ app);" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Web.IHttpModule.Init(System.Web.HttpApplication)</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="app" Type="System.Web.HttpApplication" />
</Parameters>
<Docs>
<param name="app">The current application.</param>
<summary>Calls initialization code when a <see cref="T:System.Web.Profile.ProfileModule" /> object is created.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method is not intended to be called from application code.
An <xref:System.Web.HttpApplication> is created when an ASP.NET application is started. The <xref:System.Web.HttpApplication> calls the <xref:System.Web.Profile.ProfileModule.Init%2A> method when it creates the <xref:System.Web.Profile.ProfileModule> for the application. The <xref:System.Web.Profile.ProfileModule> is specified in the configuration for an application.
]]></format>
</remarks>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/2y3fs9xs(v=vs.100)">ASP.NET Profile Properties Overview</related>
</Docs>
</Member>
<Member MemberName="MigrateAnonymous">
<MemberSignature Language="C#" Value="public event System.Web.Profile.ProfileMigrateEventHandler MigrateAnonymous;" />
<MemberSignature Language="ILAsm" Value=".event class System.Web.Profile.ProfileMigrateEventHandler MigrateAnonymous" />
<MemberSignature Language="DocId" Value="E:System.Web.Profile.ProfileModule.MigrateAnonymous" />
<MemberSignature Language="VB.NET" Value="Public Custom Event MigrateAnonymous As ProfileMigrateEventHandler " />
<MemberSignature Language="F#" Value="member this.MigrateAnonymous : System.Web.Profile.ProfileMigrateEventHandler " Usage="member this.MigrateAnonymous : System.Web.Profile.ProfileMigrateEventHandler " />
<MemberSignature Language="C++ CLI" Value="public:
 event System::Web::Profile::ProfileMigrateEventHandler ^ MigrateAnonymous;" />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.Profile.ProfileMigrateEventHandler</ReturnType>
</ReturnValue>
<Docs>
<summary>Occurs when the anonymous user for a profile logs in.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
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 by using the `Profile_MigrateAnonymous` global event, 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 a user 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. Strongly typed accessors are added to the `ProfileCommon` class for each property defined in the \<profile> configuration section. A `GetProfile` method enables you to retrieve a `ProfileCommon` object based on a user name. You can use the `GetProfile` method of the current, authenticated 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 example shows a Web.config file that enables anonymous identification and profile properties that support anonymous users.
```xml
<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>
</Member>
<Member MemberName="Personalize">
<MemberSignature Language="C#" Value="public event System.Web.Profile.ProfileEventHandler Personalize;" />
<MemberSignature Language="ILAsm" Value=".event class System.Web.Profile.ProfileEventHandler Personalize" />
<MemberSignature Language="DocId" Value="E:System.Web.Profile.ProfileModule.Personalize" />
<MemberSignature Language="VB.NET" Value="Public Custom Event Personalize As ProfileEventHandler " />
<MemberSignature Language="F#" Value="member this.Personalize : System.Web.Profile.ProfileEventHandler " Usage="member this.Personalize : System.Web.Profile.ProfileEventHandler " />
<MemberSignature Language="C++ CLI" Value="public:
 event System::Web::Profile::ProfileEventHandler ^ Personalize;" />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.Profile.ProfileEventHandler</ReturnType>
</ReturnValue>
<Docs>
<summary>Occurs before the user profile is created.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.Profile.ProfileModule.Personalize> event is raised during the <xref:System.Web.HttpApplication.AcquireRequestState?displayProperty=nameWithType> event. You can access the <xref:System.Web.Profile.ProfileModule.Personalize> event of the <xref:System.Web.Profile.ProfileModule> class in the Global.asax file for your ASP.NET application using the `Profile_Personalize` global event as shown in the example for this topic.
You can use the <xref:System.Web.Profile.ProfileModule.Personalize> event to specify a custom user profile. If the <xref:System.Web.Profile.ProfileEventArgs.Profile%2A?displayProperty=nameWithType> property value specified for the <xref:System.Web.Profile.ProfileEventHandler> event handler for the <xref:System.Web.Profile.ProfileModule.Personalize> event is set to a value that is not `null` when the <xref:System.Web.Profile.ProfileModule.Personalize> event ends, then the <xref:System.Web.Profile.ProfileModule> will use the specified value of the <xref:System.Web.Profile.ProfileEventArgs.Profile%2A?displayProperty=nameWithType> property as the value of the <xref:System.Web.HttpContext.Profile%2A> property of the current <xref:System.Web.HttpContext>.
## Examples
The following code example shows the <xref:System.Web.Profile.ProfileModule.Personalize> event declared in the Global.asax file for an application. The event code loads a user profile for a user based on role membership.
[!code-csharp[System.Web.Profile.ProfileManager.Personalize#12](~/snippets/csharp/VS_Snippets_WebNet/System.Web.Profile.ProfileManager.Personalize/CS/global.asax#12)]
[!code-vb[System.Web.Profile.ProfileManager.Personalize#12](~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Profile.ProfileManager.Personalize/VB/global.asax#12)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="ProfileAutoSaving">
<MemberSignature Language="C#" Value="public event System.Web.Profile.ProfileAutoSaveEventHandler ProfileAutoSaving;" />
<MemberSignature Language="ILAsm" Value=".event class System.Web.Profile.ProfileAutoSaveEventHandler ProfileAutoSaving" />
<MemberSignature Language="DocId" Value="E:System.Web.Profile.ProfileModule.ProfileAutoSaving" />
<MemberSignature Language="VB.NET" Value="Public Custom Event ProfileAutoSaving As ProfileAutoSaveEventHandler " />
<MemberSignature Language="F#" Value="member this.ProfileAutoSaving : System.Web.Profile.ProfileAutoSaveEventHandler " Usage="member this.ProfileAutoSaving : System.Web.Profile.ProfileAutoSaveEventHandler " />
<MemberSignature Language="C++ CLI" Value="public:
 event System::Web::Profile::ProfileAutoSaveEventHandler ^ ProfileAutoSaving;" />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.Profile.ProfileAutoSaveEventHandler</ReturnType>
</ReturnValue>
<Docs>
<summary>Occurs at the end of page execution if automatic profile saving is enabled.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.Profile.ProfileModule.ProfileAutoSaving> event is raised at the end of page execution if the <xref:System.Web.Profile.ProfileManager.AutomaticSaveEnabled%2A?displayProperty=nameWithType> property is `true`. You can access the <xref:System.Web.Profile.ProfileModule.ProfileAutoSaving> event of the <xref:System.Web.Profile.ProfileModule> class in the Global.asax file for your ASP.NET application using the `Profile_ProfileAutoSaving` global event, as shown in the example for this topic.
The <xref:System.Configuration.SettingsBase.Save%2A?displayProperty=nameWithType> method checks the <xref:System.Configuration.SettingsPropertyValue.IsDirty%2A> property value for each <xref:System.Configuration.SettingsPropertyValue> in the user profile to determine whether properties that are made up of primitive types, strings, or <xref:System.DateTime> objects have been changed. The <xref:System.Configuration.SettingsBase.Save%2A> method cannot explicitly determine whether a custom class has changed. You can use the <xref:System.Web.Profile.ProfileModule.ProfileAutoSaving> event to determine whether a custom object has been changed and then either to continue with the automatic save for modified objects or to cancel the automatic save if no objects have been modified.
To cancel the automatic profile save operation, set the <xref:System.Web.Profile.ProfileAutoSaveEventArgs.ContinueWithProfileAutoSave%2A> property to `false` in the <xref:System.Web.Profile.ProfileModule.ProfileAutoSaving> event; otherwise, set the <xref:System.Web.Profile.ProfileAutoSaveEventArgs.ContinueWithProfileAutoSave%2A> property to `true`.
There may be multiple subscribers to the <xref:System.Web.Profile.ProfileModule.ProfileAutoSaving> event. The <xref:System.Web.Profile.ProfileModule> will use the last value that the <xref:System.Web.Profile.ProfileAutoSaveEventArgs.ContinueWithProfileAutoSave%2A> property is set to. As a result, it is recommended that you explicitly set the <xref:System.Web.Profile.ProfileAutoSaveEventArgs.ContinueWithProfileAutoSave%2A> property in the <xref:System.Web.Profile.ProfileModule.ProfileAutoSaving> event whether you are canceling or continuing with the automatic save, as you may need to overwrite the value set by an earlier subscriber.
## Examples
The following code example shows the <xref:System.Web.Profile.ProfileModule.ProfileAutoSaving> event included in the Global.asax file for an ASP.NET application.
[!code-csharp[System.Web.Profile.ProfileManager.ProfileAutoSaving#11](~/snippets/csharp/VS_Snippets_WebNet/System.Web.Profile.ProfileManager.ProfileAutoSaving/CS/global.asax#11)]
[!code-vb[System.Web.Profile.ProfileManager.ProfileAutoSaving#11](~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Profile.ProfileManager.ProfileAutoSaving/VB/global.asax#11)]
]]></format>
</remarks>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/2y3fs9xs(v=vs.100)">ASP.NET Profile Properties Overview</related>
</Docs>
</Member>
</Members>
</Type>