/
ProfileBase.xml
888 lines (734 loc) · 62.2 KB
/
ProfileBase.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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
<Type Name="ProfileBase" FullName="System.Web.Profile.ProfileBase">
<TypeSignature Language="C#" Value="public class ProfileBase : System.Configuration.SettingsBase" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit ProfileBase extends System.Configuration.SettingsBase" />
<TypeSignature Language="DocId" Value="T:System.Web.Profile.ProfileBase" />
<TypeSignature Language="VB.NET" Value="Public Class ProfileBase
Inherits SettingsBase" />
<TypeSignature Language="F#" Value="type ProfileBase = class
 inherit SettingsBase" />
<TypeSignature Language="C++ CLI" Value="public ref class ProfileBase : System::Configuration::SettingsBase" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Configuration.SettingsBase</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Provides untyped access to profile property values and information.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
ASP.NET uses the <xref:System.Web.Profile.ProfileBase> class to create the class used for the user profile. 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](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)) configuration section. The strongly typed accessors of the `ProfileCommon` class call the <xref:System.Web.Profile.ProfileBase.GetPropertyValue%2A> and <xref:System.Web.Profile.ProfileBase.SetPropertyValue%2A> methods of the <xref:System.Web.Profile.ProfileBase> base class to retrieve and set profile property values, respectively. An instance of the `ProfileCommon` class is set as the value of the <xref:System.Web.HttpContext.Profile%2A> property for the ASP.NET application.
To create an instance of a user profile in an ASP.NET application, it is recommended that you use the <xref:System.Web.Profile.ProfileBase.Create%2A> method.
## Notes to Inheritors
You can create a custom profile implementation that inherits from the <xref:System.Web.Profile.ProfileBase> abstract class and defines properties for the user profile that are not specified in the [profile](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)) configuration element. You can specify a custom user-profile type in the web.config file with the `inherits` attribute of the [profile](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)) configuration element, as shown in the following example. The code for the `EmployeeProfile` class is included in the Example section of this topic.
:::code language="xml" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.Profile.HttpProfileBase/CS/config.xml":::
## Examples
The following code example shows a Web.config file that specifies a user profile that contains a `ZipCode` property of type `string` and a `RecentSearchList` property of type <xref:System.Collections.Specialized.StringCollection>. The generated <xref:System.Web.HttpContext.Profile%2A> property of the current <xref:System.Web.HttpContext> will have strongly typed accessors for each of the specified properties.
```xml
<configuration>
<system.web>
<anonymousIdentification enabled="true" />
<profile enabled="true" defaultProvider="SqlProvider" >
<properties>
<add name="ZipCode" allowAnonymous="true" />
<add name="RecentSearchList"
type="System.Collections.Specialized.StringCollection"
serializeAs="Xml"
allowAnonymous="true" />
</properties>
</profile>
</system.web>
</configuration>
```
The following example shows an ASP.NET page that reads and sets the `ZipCode` property specified for the user profile. Before attempting to run this code, set the provider to the default `AspNetSqlProvider` in the ASP.NET configuration settings for the Web site.
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.Profile.HttpProfileBase/CS/defaultcs.aspx" id="Snippet1":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Profile.HttpProfileBase/VB/defaultvb.aspx" id="Snippet1":::
The following code example defines a class that inherits from the <xref:System.Web.Profile.ProfileBase> class to create a custom profile. The type of the custom profile is specified in the `inherits` attribute of the [profile](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)) configuration element in the Web.config file for an application.
> [!IMPORTANT]
> This example contains a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see [Script Exploits Overview](https://docs.microsoft.com/previous-versions/aspnet/w1sw53ds(v=vs.100)).
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.Profile.ProfileBase/CS/employeeprofile.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Profile.ProfileBase/VB/employeeprofile.vb" id="Snippet1":::
]]></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 ProfileBase ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Profile.ProfileBase.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:
 ProfileBase();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters />
<Docs>
<summary>Creates an instance of the <see cref="T:System.Web.Profile.ProfileBase" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
ASP.NET uses the <xref:System.Web.Profile.ProfileBase> class to create the class used for the user profile. 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](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)) configuration section. The strongly typed accessors of the `ProfileCommon` class call the <xref:System.Web.Profile.ProfileBase.GetPropertyValue%2A> and <xref:System.Web.Profile.ProfileBase.SetPropertyValue%2A> methods of the <xref:System.Web.Profile.ProfileBase> base class to retrieve and set profile property values, respectively. An instance of the `ProfileCommon` class is set as the value of the <xref:System.Web.HttpContext.Profile%2A> property for the ASP.NET application.
> [!NOTE]
> The base class used to generate the class stored in the <xref:System.Web.HttpContext.Profile%2A> property can be overridden using the `inherits` attribute of the [profile](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)) section of the configuration file. In this case you would specify a custom class that inherits from the <xref:System.Web.Profile.ProfileBase> base class.
This constructor is not intended to be used from application code. To create an instance of a user profile, use the <xref:System.Web.Profile.ProfileBase.Create%2A> method.
## Examples
The following Web.config file specifies a user profile that contains a `ZipCode` property of type `string` and a `RecentSearchList` property of type <xref:System.Collections.Specialized.StringCollection>. The generated <xref:System.Web.HttpContext.Profile%2A> property of the current <xref:System.Web.HttpContext> will have strongly typed accessors for each of the specified properties.
```xml
<configuration>
<connectionStrings>
<add name="SqlServices" connectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=aspnetdb;" />
</connectionStrings>
<system.web>
<anonymousIdentification enabled="true" />
<profile defaultProvider="SqlProvider" >
<providers>
<add
name="SqlProvider"
connectionStringName="SqlServices"
applicationName="ProfileBaseApplication"
type="System.Web.Profile.SqlProfileProvider" />
</providers>
<properties>
<add name="ZipCode" allowAnonymous="true" />
<add name="RecentSearchList"
type="System.Collections.Specialized.StringCollection"
serializeAs="Xml"
allowAnonymous="true" />
</properties>
</profile>
</system.web>
</configuration>
```
The following ASP.NET page reads and sets the `ZipCode` property specified for the user profile.
> [!IMPORTANT]
> This example contains a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see [Script Exploits Overview](https://docs.microsoft.com/previous-versions/aspnet/w1sw53ds(v=vs.100)).
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.Profile.HttpProfileBase/CS/defaultcs.aspx" id="Snippet1":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Profile.HttpProfileBase/VB/defaultvb.aspx" id="Snippet1":::
]]></format>
</remarks>
<exception cref="T:System.Configuration.Provider.ProviderException">The <see langword="enabled" /> attribute of the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section of the Web.config file is <see langword="false" />.</exception>
<exception cref="T:System.Configuration.ConfigurationErrorsException">A property type specified in the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section of the Web.config file could not be created.
-or-
The <see langword="allowAnonymous" /> attribute for a property in the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section of the Web.config file is set to <see langword="true" /> and the <see langword="enabled" /> attribute of the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/91ka2e6a(v%3dvs.100)"><anonymousIdentification></see> element is set to <see langword="false" />.
-or-
The <see langword="serializeAs" /> attribute for a property in the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section of the Web.config file is set to <see cref="F:System.Configuration.SettingsSerializeAs.Binary" /> and the <see cref="P:System.Type.IsSerializable" /> property of the specified <see langword="type" /> returns <see langword="false" />.
-or-
The name of a provider specified using the <see langword="provider" /> attribute of a profile property could not be found in the <see cref="P:System.Web.Profile.ProfileManager.Providers" /> collection.
-or-
The <see langword="type" /> specified for a profile property could not be found.
-or-
A profile property was specified with a name that matches a property name on the base class specified in the <see langword="inherits" /> attribute of the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section.</exception>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/2y3fs9xs(v=vs.100)">ASP.NET Profile Properties Overview</related>
</Docs>
</Member>
<MemberGroup MemberName="Create">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Creates an instance of a user profile.</summary>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/2y3fs9xs(v=vs.100)">ASP.NET Profile Properties Overview</related>
</Docs>
</MemberGroup>
<Member MemberName="Create">
<MemberSignature Language="C#" Value="public static System.Web.Profile.ProfileBase Create (string username);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Web.Profile.ProfileBase Create(string username) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Profile.ProfileBase.Create(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function Create (username As String) As ProfileBase" />
<MemberSignature Language="F#" Value="static member Create : string -> System.Web.Profile.ProfileBase" Usage="System.Web.Profile.ProfileBase.Create username" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Web::Profile::ProfileBase ^ Create(System::String ^ username);" />
<MemberType>Method</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>
<ReturnValue>
<ReturnType>System.Web.Profile.ProfileBase</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="username" Type="System.String" />
</Parameters>
<Docs>
<param name="username">The name of the user to create a profile for.</param>
<summary>Used by ASP.NET to create an instance of a profile for the specified user name.</summary>
<returns>An <see cref="T:System.Web.Profile.ProfileBase" /> that represents the profile for the specified user.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.Profile.ProfileBase.Create%2A> method creates and initializes a new profile instance and is useful for applications that use a custom profile object or manage user profiles in a non-ASP.NET environment.
This overload of the <xref:System.Web.Profile.ProfileBase.Create%2A> method assumes that the specified user name is an authenticated user.
## Examples
The following code example creates an instance of a custom profile object, sets a property, and saves the profile to the data source.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.Profile.ProfileBase.Create/CS/profileBaseCreatecs.aspx.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Profile.ProfileBase.Create/VB/profileBaseCreatevb.aspx.vb" id="Snippet1":::
]]></format>
</remarks>
<exception cref="T:System.Configuration.Provider.ProviderException">The <see langword="enabled" /> attribute of the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section of the Web.config file is <see langword="false" />.</exception>
<exception cref="T:System.Web.HttpException">The current hosting permission level is less than <see cref="F:System.Web.AspNetHostingPermissionLevel.Medium" />.</exception>
<exception cref="T:System.Configuration.ConfigurationErrorsException">A property type specified in the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section of the Web.config file could not be created.
-or-
The <see langword="allowAnonymous" /> attribute for a property in the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section of the Web.config file is set to <see langword="true" /> and the <see langword="enabled" /> attribute of the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/91ka2e6a(v%3dvs.100)"><anonymousIdentification></see> element is set to <see langword="false" />.
-or-
The <see langword="serializeAs" /> attribute for a property in the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section of the Web.config file is set to <see cref="F:System.Configuration.SettingsSerializeAs.Binary" /> and the <see cref="P:System.Type.IsSerializable" /> property of the specified <see langword="type" /> returns <see langword="false" />.
-or-
The name of a provider specified using the <see langword="provider" /> attribute of a profile property could not be found in the <see cref="P:System.Web.Profile.ProfileManager.Providers" /> collection.
-or-
The <see langword="type" /> specified for a profile property could not be found.
-or-
A profile property was specified with a name that matches a property name on the base class specified in the <see langword="inherits" /> attribute of the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section.</exception>
<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="Create">
<MemberSignature Language="C#" Value="public static System.Web.Profile.ProfileBase Create (string username, bool isAuthenticated);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Web.Profile.ProfileBase Create(string username, bool isAuthenticated) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Profile.ProfileBase.Create(System.String,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function Create (username As String, isAuthenticated As Boolean) As ProfileBase" />
<MemberSignature Language="F#" Value="static member Create : string * bool -> System.Web.Profile.ProfileBase" Usage="System.Web.Profile.ProfileBase.Create (username, isAuthenticated)" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Web::Profile::ProfileBase ^ Create(System::String ^ username, bool isAuthenticated);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.Profile.ProfileBase</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="username" Type="System.String" />
<Parameter Name="isAuthenticated" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="username">The name of the user to create a profile for.</param>
<param name="isAuthenticated">
<see langword="true" /> to indicate the user is authenticated; <see langword="false" /> to indicate the user is anonymous.</param>
<summary>Used by ASP.NET to create an instance of a profile for the specified user name. Takes a parameter indicating whether the user is authenticated or anonymous.</summary>
<returns>A <see cref="T:System.Web.Profile.ProfileBase" /> object that represents the profile for the specified user.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.Profile.ProfileBase.Create%2A> method creates and initializes a new profile instance and is useful for applications that use a custom profile object or manage user profiles in a non-ASP.NET environment.
This overload of the <xref:System.Web.Profile.ProfileBase.Create%2A> method can be used to create a profile for an authenticated user or an anonymous user.
## Examples
The following code example creates an instance of a custom profile object, sets a property, and saves the profile to the data source.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.Profile.ProfileBase.Create/CS/profileBaseCreatecs.aspx.cs" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Profile.ProfileBase.Create/VB/profileBaseCreatevb.aspx.vb" id="Snippet2":::
]]></format>
</remarks>
<exception cref="T:System.Configuration.Provider.ProviderException">The <see langword="enabled" /> attribute of the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section of the Web.config file is <see langword="false" />.</exception>
<exception cref="T:System.Web.HttpException">The current hosting permission level is less than <see cref="F:System.Web.AspNetHostingPermissionLevel.Medium" />.</exception>
<exception cref="T:System.Configuration.ConfigurationErrorsException">A property type specified in the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section of the Web.config file could not be created.
-or-
The <see langword="allowAnonymous" /> attribute for a property in the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section of the Web.config file is set to <see langword="true" /> and the <see langword="enabled" /> attribute of the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/91ka2e6a(v%3dvs.100)"><anonymousIdentification></see> element is set to <see langword="false" />.
-or-
The <see langword="serializeAs" /> attribute for a property in the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section of the Web.config file is set to <see cref="F:System.Configuration.SettingsSerializeAs.Binary" /> and the <see cref="P:System.Type.IsSerializable" /> property of the specified <see langword="type" /> returns <see langword="false" />.
-or-
The name of a provider specified using the <see langword="provider" /> attribute of a profile property could not be found in the <see cref="P:System.Web.Profile.ProfileManager.Providers" /> collection.
-or-
The <see langword="type" /> specified for a profile property could not be found.
-or-
A profile property was specified with a name that matches a property name on the base class specified in the <see langword="inherits" /> attribute of the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section.</exception>
<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="GetProfileGroup">
<MemberSignature Language="C#" Value="public System.Web.Profile.ProfileGroupBase GetProfileGroup (string groupName);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance class System.Web.Profile.ProfileGroupBase GetProfileGroup(string groupName) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Profile.ProfileBase.GetProfileGroup(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function GetProfileGroup (groupName As String) As ProfileGroupBase" />
<MemberSignature Language="F#" Value="member this.GetProfileGroup : string -> System.Web.Profile.ProfileGroupBase" Usage="profileBase.GetProfileGroup groupName" />
<MemberSignature Language="C++ CLI" Value="public:
 System::Web::Profile::ProfileGroupBase ^ GetProfileGroup(System::String ^ groupName);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.Profile.ProfileGroupBase</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="groupName" Type="System.String" />
</Parameters>
<Docs>
<param name="groupName">The name of the group of properties.</param>
<summary>Gets a group of properties identified by a group name.</summary>
<returns>A <see cref="T:System.Web.Profile.ProfileGroupBase" /> object for a group of properties configured with the specified group name.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Profile properties can be separated into groups for better organization. The <xref:System.Web.Profile.ProfileBase.GetProfileGroup%2A> property can be used to retrieve a group of properties by the group name. You can also access a profile property in a group by specifying the group name as a member of the `Profile` property available on each page. For example, the `ZipCode` profile property that is a member of the `Address` profile group could be accessed using `Profile.Address.ZipCode`.
## Examples
The following Web.config file specifies a user profile that contains group of properties with a group name of `Address`. The grouped properties generated for the <xref:System.Web.HttpContext.Profile%2A> property of the current <xref:System.Web.HttpContext> will be preceded by the group name. For example, `Profile.Address.Street`.
```xml
<configuration>
<connectionStrings>
<add name="SqlServices" connectionString=
"Data Source=localhost;Integrated Security=SSPI;Initial Catalog=aspnetdb;" />
</connectionStrings>
<system.web>
<authentication mode="Forms" >
<forms loginUrl="login.aspx"
name=".ASPXFORMSAUTH" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
<membership defaultProvider="SqlProvider"
userIsOnlineTimeWindow="15">
<providers>
<clear />
<add
name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="SqlServices"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
requiresUniqueEmail="false"
passwordFormat="Hashed"
applicationName="MyApplication" />
</providers>
</membership>
<profile defaultProvider="SqlProvider">
<providers>
<add
name="SqlProvider"
connectionStringName="SqlServices"
applicationName="MyApplication"
type="System.Web.Profile.SqlProfileProvider" />
</providers>
<properties>
<add name="ZipCode" />
<group name="Address">
<add name="Street" />
<add name="City" />
<add name="State" />
<add name="CountryOrRegion" />
</group>
</properties>
</profile>
</system.web>
</configuration>
```
The following ASP.NET page reads and sets the grouped properties specified for the user profile.
> [!IMPORTANT]
> This example contains a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see [Script Exploits Overview](https://docs.microsoft.com/previous-versions/aspnet/w1sw53ds(v=vs.100)).
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.Profile.HttpProfileGroupBase/CS/defaultcs.aspx" id="Snippet1":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Profile.HttpProfileGroupBase/VB/defaultvb.aspx" id="Snippet1":::
]]></format>
</remarks>
<exception cref="T:System.Configuration.Provider.ProviderException">The specified profile property group name was not found in the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">properties</see> configuration section.</exception>
<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="GetPropertyValue">
<MemberSignature Language="C#" Value="public object GetPropertyValue (string propertyName);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance object GetPropertyValue(string propertyName) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Profile.ProfileBase.GetPropertyValue(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function GetPropertyValue (propertyName As String) As Object" />
<MemberSignature Language="F#" Value="member this.GetPropertyValue : string -> obj" Usage="profileBase.GetPropertyValue propertyName" />
<MemberSignature Language="C++ CLI" Value="public:
 System::Object ^ GetPropertyValue(System::String ^ propertyName);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="propertyName" Type="System.String" />
</Parameters>
<Docs>
<param name="propertyName">The name of the profile property.</param>
<summary>Gets the value of a profile property.</summary>
<returns>The value of the specified profile property, typed as <see langword="object" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
ASP.NET uses the <xref:System.Web.Profile.ProfileBase> class to create the class used for the user profile. 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](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)) configuration section. The strongly typed accessors of the `ProfileCommon` class call the <xref:System.Web.Profile.ProfileBase.GetPropertyValue%2A> method to retrieve untyped values from the <xref:System.Web.Profile.ProfileProvider> that the generated accessor then casts as the specified type and returns as the property value.
You can use the <xref:System.Web.Profile.ProfileBase.GetPropertyValue%2A> method to retrieve property values of the user profile for your application by name. Returned values are untyped and must be cast as the specific object type when retrieved. For strongly typed access to profile property values, you can access the property by name as a member of the Profile property available on each page, for example, `Profile.CustomerAddress`.
## Examples
The following code example shows an ASP.NET page that reads and sets the `ZipCode` property specified for the user profile. For an example of a Web.config file that specifies properties for the user profile, see the example provided for the <xref:System.Web.Profile.ProfileBase> class.
> [!IMPORTANT]
> This example contains a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see [Script Exploits Overview](https://docs.microsoft.com/previous-versions/aspnet/w1sw53ds(v=vs.100)).
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.Profile.HttpProfileBase/CS/defaultcs.aspx" id="Snippet1":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Profile.HttpProfileBase/VB/defaultvb.aspx" id="Snippet1":::
]]></format>
</remarks>
<exception cref="T:System.Configuration.Provider.ProviderException">An attempt was made to set a property value on an anonymous profile where the property's <see langword="allowAnonymous" /> attribute is <see langword="false" />.</exception>
<exception cref="T:System.Configuration.SettingsPropertyNotFoundException">There are no properties defined for the current profile.
-or-
The specified profile property name does not exist in the current profile.
-or-
The provider for the specified profile property did not recognize the specified property.</exception>
<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="Initialize">
<MemberSignature Language="C#" Value="public void Initialize (string username, bool isAuthenticated);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Initialize(string username, bool isAuthenticated) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Profile.ProfileBase.Initialize(System.String,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Sub Initialize (username As String, isAuthenticated As Boolean)" />
<MemberSignature Language="F#" Value="override this.Initialize : string * bool -> unit" Usage="profileBase.Initialize (username, isAuthenticated)" />
<MemberSignature Language="C++ CLI" Value="public:
 void Initialize(System::String ^ username, bool isAuthenticated);" />
<MemberType>Method</MemberType>
<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="username" Type="System.String" />
<Parameter Name="isAuthenticated" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="username">The name of the user to initialize the profile for.</param>
<param name="isAuthenticated">
<see langword="true" /> to indicate the user is authenticated; <see langword="false" /> to indicate the user is anonymous.</param>
<summary>Initializes the profile property values and information for the current user.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method is not intended to be used from your code. Use one of the <xref:System.Web.Profile.ProfileBase.Create%2A> overloads to create an instance of the user profile.
]]></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="IsAnonymous">
<MemberSignature Language="C#" Value="public bool IsAnonymous { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool IsAnonymous" />
<MemberSignature Language="DocId" Value="P:System.Web.Profile.ProfileBase.IsAnonymous" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property IsAnonymous As Boolean" />
<MemberSignature Language="F#" Value="member this.IsAnonymous : bool" Usage="System.Web.Profile.ProfileBase.IsAnonymous" />
<MemberSignature Language="C++ CLI" Value="public:
 property bool IsAnonymous { bool get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a value indicating whether the user profile is for an anonymous user.</summary>
<value>
<see langword="true" /> if the user profile is for an anonymous user; otherwise, <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Anonymous access to the user profile is enabled using the [anonymousIdentification](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/91ka2e6a(v%3dvs.100)) configuration section and the allowAnonymous attribute of the [add](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164646(v%3dvs.100)) configuration element used to specify profile properties.
]]></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="IsDirty">
<MemberSignature Language="C#" Value="public bool IsDirty { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool IsDirty" />
<MemberSignature Language="DocId" Value="P:System.Web.Profile.ProfileBase.IsDirty" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property IsDirty As Boolean" />
<MemberSignature Language="F#" Value="member this.IsDirty : bool" Usage="System.Web.Profile.ProfileBase.IsDirty" />
<MemberSignature Language="C++ CLI" Value="public:
 property bool IsDirty { bool get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a value indicating whether any of the profile properties have been modified.</summary>
<value>
<see langword="true" /> if any of the profile properties have been modified; otherwise, <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.Profile.ProfileBase.IsDirty%2A> property can be used by a profile provider during the <xref:System.Configuration.SettingsBase.Save%2A> method to determine whether properties that are made up of primitive types, strings, or <xref:System.DateTime> objects have been changed. Changed properties are then updated by the profile provider in the <xref:System.Configuration.SettingsBase.Save%2A> method. The <xref:System.Configuration.SettingsBase.Save%2A> method is automatically called at the end of page execution if the <xref:System.Web.Profile.ProfileManager.AutomaticSaveEnabled%2A> property is `true`
A profile provider called in the <xref:System.Configuration.SettingsBase.Save%2A> method cannot explicitly determine whether a profile property with a custom class type or a complex type, such as a collection, has changed. You can use the <xref:System.Web.Profile.ProfileModule.ProfileAutoSaving> event to determine whether a custom object has been modified and to continue with the automatic save for modified objects or cancel the automatic save if no objects have been modified. The default behavior of the <xref:System.Web.Profile.ProfileBase> class is to set the <xref:System.Web.Profile.ProfileBase.IsDirty%2A> property to `true` for properties that are of a custom or complex type the first time the property is accessed.
]]></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="Item">
<MemberSignature Language="C#" Value="public override object this[string propertyName] { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance object Item(string)" />
<MemberSignature Language="DocId" Value="P:System.Web.Profile.ProfileBase.Item(System.String)" />
<MemberSignature Language="VB.NET" Value="Default Public Overrides Property Item(propertyName As String) As Object" />
<MemberSignature Language="F#" Value="member this.Item(string) : obj with get, set" Usage="System.Web.Profile.ProfileBase.Item" />
<MemberSignature Language="C++ CLI" Value="public:
 virtual property System::Object ^ default[System::String ^] { System::Object ^ get(System::String ^ propertyName); void set(System::String ^ propertyName, System::Object ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="propertyName" Type="System.String" />
</Parameters>
<Docs>
<param name="propertyName">The name of the profile property.</param>
<summary>Gets or sets a profile property value indexed by the property name.</summary>
<value>The value of the specified profile property, typed as <see langword="object" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can use this property to retrieve or set the property values of the user profile for your application by name. Returned values are typed as `object` and must be cast as the specific object type when retrieved. For strongly typed access to profile property values, you can access the property by name as a member of the `Profile` property available on each page, for example, `Profile.CustomerAddress`.
## Examples
The following code example lists the names of the properties in the user profile by binding the <xref:System.Configuration.SettingsProperty.Name%2A> property from the static <xref:System.Web.Profile.ProfileBase.Properties%2A> collection of <xref:System.Configuration.SettingsProperty> objects to a <xref:System.Web.UI.WebControls.GridView> control. The selected property value is retrieved by name using the <xref:System.Web.Profile.ProfileBase.Item%2A> collection. For an example of a Web.config file that specifies properties for the user profile, see the example provided for the <xref:System.Web.Profile.ProfileBase> class.
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.Profile.HttpProfileBase/CS/ViewProfilecs.aspx" id="Snippet2":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Profile.HttpProfileBase/VB/ViewProfilevb.aspx" id="Snippet2":::
]]></format>
</remarks>
<exception cref="T:System.Configuration.Provider.ProviderException">An attempt was made to set a property value on an anonymous profile where the property's <see langword="allowAnonymous" /> attribute is <see langword="false" />.</exception>
<exception cref="T:System.Configuration.SettingsPropertyNotFoundException">There are no properties defined for the current profile.
-or-
The specified profile property name does not exist in the current profile.
-or-
The provider for the specified profile property did not recognize the specified property.</exception>
<exception cref="T:System.Configuration.SettingsPropertyIsReadOnlyException">An attempt was made to set a property value that was marked as read-only.</exception>
<exception cref="T:System.Configuration.SettingsPropertyWrongTypeException">An attempt was made to assign a value to a property using an incompatible type.</exception>
<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="LastActivityDate">
<MemberSignature Language="C#" Value="public DateTime LastActivityDate { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.DateTime LastActivityDate" />
<MemberSignature Language="DocId" Value="P:System.Web.Profile.ProfileBase.LastActivityDate" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property LastActivityDate As DateTime" />
<MemberSignature Language="F#" Value="member this.LastActivityDate : DateTime" Usage="System.Web.Profile.ProfileBase.LastActivityDate" />
<MemberSignature Language="C++ CLI" Value="public:
 property DateTime LastActivityDate { DateTime get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.DateTime</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the most recent date and time that the profile was read or modified.</summary>
<value>The most recent date and time that the profile was read or modified by the default provider.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This property value is only modified by the default profile provider. Changes made to profile properties by a provider other than the default profile provider do not affect the value of the <xref:System.Web.Profile.ProfileBase.LastActivityDate%2A> property.
]]></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="LastUpdatedDate">
<MemberSignature Language="C#" Value="public DateTime LastUpdatedDate { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.DateTime LastUpdatedDate" />
<MemberSignature Language="DocId" Value="P:System.Web.Profile.ProfileBase.LastUpdatedDate" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property LastUpdatedDate As DateTime" />
<MemberSignature Language="F#" Value="member this.LastUpdatedDate : DateTime" Usage="System.Web.Profile.ProfileBase.LastUpdatedDate" />
<MemberSignature Language="C++ CLI" Value="public:
 property DateTime LastUpdatedDate { DateTime get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.DateTime</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the most recent date and time that the profile was modified.</summary>
<value>The most recent date and time that the profile was modified by the default provider.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This property value is only modified by the default profile provider. Changes made to profile properties by a provider other than the default profile provider do not affect the value of the <xref:System.Web.Profile.ProfileBase.LastUpdatedDate%2A> property.
]]></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="Properties">
<MemberSignature Language="C#" Value="public static System.Configuration.SettingsPropertyCollection Properties { get; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Configuration.SettingsPropertyCollection Properties" />
<MemberSignature Language="DocId" Value="P:System.Web.Profile.ProfileBase.Properties" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly Property Properties As SettingsPropertyCollection" />
<MemberSignature Language="F#" Value="static member Properties : System.Configuration.SettingsPropertyCollection" Usage="System.Web.Profile.ProfileBase.Properties" />
<MemberSignature Language="C++ CLI" Value="public:
 static property System::Configuration::SettingsPropertyCollection ^ Properties { System::Configuration::SettingsPropertyCollection ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Configuration.SettingsPropertyCollection</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a collection of <see cref="T:System.Configuration.SettingsProperty" /> objects for each property in the profile.</summary>
<value>A <see cref="T:System.Configuration.SettingsPropertyCollection" /> of <see cref="T:System.Configuration.SettingsProperty" /> objects for each property in the profile for the application.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can use this property to get information about the profile properties configured for an application, including property names and types. You can also reference the <xref:System.Web.Profile.ProfileProvider> of each property. A <xref:System.Web.Profile.ProfileProvider> manages storage and retrieval of property values to and from the data source.
## Examples
The following code example lists the names of the properties in the user profile by binding the <xref:System.Configuration.SettingsProperty.Name%2A> property from the static <xref:System.Web.Profile.ProfileBase.Properties%2A> collection of <xref:System.Configuration.SettingsProperty> objects to a <xref:System.Web.UI.WebControls.GridView> control. The selected property value is retrieved by name using the <xref:System.Web.Profile.ProfileBase.Item%2A> collection. For an example of a Web.config file that specifies properties for the user profile, see the example provided for the <xref:System.Web.Profile.ProfileBase> class.
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.Profile.HttpProfileBase/CS/ViewProfilecs.aspx" id="Snippet2":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Profile.HttpProfileBase/VB/ViewProfilevb.aspx" id="Snippet2":::
]]></format>
</remarks>
<exception cref="T:System.Configuration.ConfigurationErrorsException">A property type specified in the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section of the Web.config file could not be created.
-or-
The <see langword="allowAnonymous" /> attribute for a property in the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section of the Web.config file is set to <see langword="true" /> and the <see langword="enabled" /> attribute of the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/91ka2e6a(v%3dvs.100)"><anonymousIdentification></see> element is set to <see langword="false" />.
-or-
The <see langword="serializeAs" /> attribute for a property in the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section of the Web.config file is set to <see cref="F:System.Configuration.SettingsSerializeAs.Binary" /> and the <see cref="P:System.Type.IsSerializable" /> property of the specified <see langword="type" /> returns <see langword="false" />.
-or-
The name of a provider specified using the <see langword="provider" /> attribute of a profile property could not be found in the <see cref="P:System.Web.Profile.ProfileManager.Providers" /> collection.
-or-
The <see langword="type" /> specified for a profile property could not be found.
-or-
A profile property was specified with a name that matches a property name on the base class specified in the <see langword="inherits" /> attribute of the <see href="https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)">profile</see> section.</exception>
<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="Save">
<MemberSignature Language="C#" Value="public override void Save ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance void Save() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Profile.ProfileBase.Save" />
<MemberSignature Language="VB.NET" Value="Public Overrides Sub Save ()" />
<MemberSignature Language="F#" Value="override this.Save : unit -> unit" Usage="profileBase.Save " />
<MemberSignature Language="C++ CLI" Value="public:
 override void Save();" />
<MemberType>Method</MemberType>
<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>Updates the profile data source with changed profile property values.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.Profile.ProfileBase.Save%2A> method writes modified profile property values to the data source. The profile provider can reduce the amount of activity at the data source by performing updates only when the <xref:System.Web.Profile.ProfileBase.IsDirty%2A> property is set to `true`. This is the case for the default <xref:System.Web.Profile.SqlProfileProvider>. After the <xref:System.Web.Profile.ProfileBase.Save%2A> method has saved the property values to the data source, <xref:System.Web.Profile.ProfileBase.IsDirty%2A> is set to `false`.
You can use the <xref:System.Web.Profile.ProfileModule.ProfileAutoSaving> event to implement custom logic that determines whether a profile property with a custom type or a complex type has been modified and continue with the automatic save for modified objects or cancel the automatic save if no objects have been modified.
]]></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="SetPropertyValue">
<MemberSignature Language="C#" Value="public void SetPropertyValue (string propertyName, object propertyValue);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void SetPropertyValue(string propertyName, object propertyValue) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.Profile.ProfileBase.SetPropertyValue(System.String,System.Object)" />
<MemberSignature Language="VB.NET" Value="Public Sub SetPropertyValue (propertyName As String, propertyValue As Object)" />
<MemberSignature Language="F#" Value="member this.SetPropertyValue : string * obj -> unit" Usage="profileBase.SetPropertyValue (propertyName, propertyValue)" />
<MemberSignature Language="C++ CLI" Value="public:
 void SetPropertyValue(System::String ^ propertyName, System::Object ^ propertyValue);" />
<MemberType>Method</MemberType>
<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="propertyName" Type="System.String" />
<Parameter Name="propertyValue" Type="System.Object" />
</Parameters>
<Docs>
<param name="propertyName">The name of the property to set.</param>
<param name="propertyValue">The value to assign to the property.</param>
<summary>Sets the value of a profile property.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
ASP.NET uses the <xref:System.Web.Profile.ProfileBase> class to create the class used for the user profile. 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](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164644(v%3dvs.100)) configuration section. The strongly typed accessors of the `ProfileCommon` class call the <xref:System.Web.Profile.ProfileBase.SetPropertyValue%2A> method to pass property values to the <xref:System.Web.Profile.ProfileProvider> to be stored at the data source.
You can use the <xref:System.Web.Profile.ProfileBase.SetPropertyValue%2A> method to assign property values in the user profile for your application by name. Values are untyped, and type checking will be done at run time, not compile time. For strongly typed access to profile property values, you can access the property by name as a member of the `Profile` property that is available on each page, for example, `Profile.CustomerAddress`.
## Examples
The following code example shows an ASP.NET page that reads and sets the `ZipCode` property specified for the user profile. For an example of a Web.config file that specifies properties for the user profile, see the example provided for the <xref:System.Web.Profile.ProfileBase> class.
> [!IMPORTANT]
> This example contains a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see [Script Exploits Overview](https://docs.microsoft.com/previous-versions/aspnet/w1sw53ds(v=vs.100)).
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.Profile.HttpProfileBase/CS/defaultcs.aspx" id="Snippet1":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Profile.HttpProfileBase/VB/defaultvb.aspx" id="Snippet1":::
]]></format>
</remarks>
<exception cref="T:System.Configuration.Provider.ProviderException">An attempt was made to set a property value on an anonymous profile where the property's <see langword="allowAnonymous" /> attribute is <see langword="false" />.</exception>
<exception cref="T:System.Configuration.SettingsPropertyNotFoundException">There are no properties defined for the current profile.
-or-
The specified profile property name does not exist in the current profile.
-or-
The provider for the specified profile property did not recognize the specified property.</exception>
<exception cref="T:System.Configuration.SettingsPropertyIsReadOnlyException">An attempt was made to set a value on a property that was marked as read-only.</exception>
<exception cref="T:System.Configuration.SettingsPropertyWrongTypeException">An attempt was made to assign a value to a property using an incompatible type.</exception>
<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="UserName">
<MemberSignature Language="C#" Value="public string UserName { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string UserName" />
<MemberSignature Language="DocId" Value="P:System.Web.Profile.ProfileBase.UserName" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property UserName As String" />
<MemberSignature Language="F#" Value="member this.UserName : string" Usage="System.Web.Profile.ProfileBase.UserName" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ UserName { System::String ^ get(); };" />
<MemberType>Property</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#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the user name for the profile.</summary>
<value>The user name for the profile or the anonymous-user identifier assigned to the profile.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.Profile.ProfileBase.UserName%2A> property returns either the name of the authenticated user that the profile is associated with or the anonymous user identifier assigned to the profile if the <xref:System.Web.Profile.ProfileBase.IsAnonymous%2A> property is `true`.
Anonymous access to the user profile is enabled using the [anonymousIdentification](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/91ka2e6a(v%3dvs.100)) configuration section and the allowAnonymous attribute of the [add](https://docs.microsoft.com/previous-versions/dotnet/netframework-4.0/ms164646(v%3dvs.100)) configuration element used to specify profile properties.
]]></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>