-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
CreatingCookieEventArgs.xml
263 lines (227 loc) · 20.5 KB
/
CreatingCookieEventArgs.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
<Type Name="CreatingCookieEventArgs" FullName="System.Web.ApplicationServices.CreatingCookieEventArgs">
<TypeSignature Language="C#" Value="public class CreatingCookieEventArgs : EventArgs" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit CreatingCookieEventArgs extends System.EventArgs" />
<TypeSignature Language="DocId" Value="T:System.Web.ApplicationServices.CreatingCookieEventArgs" />
<TypeSignature Language="VB.NET" Value="Public Class CreatingCookieEventArgs
Inherits EventArgs" />
<TypeSignature Language="F#" Value="type CreatingCookieEventArgs = class
 inherit EventArgs" />
<TypeSignature Language="C++ CLI" Value="public ref class CreatingCookieEventArgs : EventArgs" />
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.EventArgs</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Provides data for the <see cref="E:System.Web.ApplicationServices.AuthenticationService.CreatingCookie" /> event.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.ApplicationServices.CreatingCookieEventArgs> class supplies values to any <xref:System.Web.ApplicationServices.AuthenticationService.CreatingCookie> event handler. By using the properties of this class, you can retrieve user credentials when you create a custom authentication cookie.
The <xref:System.Web.ApplicationServices.AuthenticationService> class raises the <xref:System.Web.ApplicationServices.AuthenticationService.CreatingCookie> event when it sets the authentication cookie, after the user credentials have been authenticated. The <xref:System.Web.ApplicationServices.AuthenticationService> class constructs a <xref:System.Web.ApplicationServices.CreatingCookieEventArgs> object and passes it to any <xref:System.Web.ApplicationServices.AuthenticationService.CreatingCookie> event handler.
You retrieve the user credentials through the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.UserName%2A><xref:System.Web.ApplicationServices.CreatingCookieEventArgs.Password%2A>, and <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.CustomCredential%2A> properties. The <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.CustomCredential%2A> property can contain any custom values that you need in order to authenticate, such as an identification number. The <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.IsPersistent%2A> property indicates whether the authentication cookie should be retained past the current session. Set the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.CookieIsSet%2A> property to `true` if you create the authentication cookie, so that the <xref:System.Web.ApplicationServices.AuthenticationService> class does not create the cookie.
## Examples
The following example shows an event handler for the <xref:System.Web.ApplicationServices.AuthenticationService.CreatingCookie> event. The handler retrieves user values from the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs> object to customize the authentication cookie. The handler saves the value from the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.CustomCredential%2A> property in the authentication ticket and sets the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.CookieIsSet%2A> property to `true` to indicate that the authentication cookie has been created.
[!code-csharp[System.Web.Security.LoginService.CreatingCookieEventArgs#2](~/snippets/csharp/VS_Snippets_WebNet/System.Web.Security.LoginService.CreatingCookieEventArgs/cs/Global.asax#2)]
[!code-vb[System.Web.Security.LoginService.CreatingCookieEventArgs#2](~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Security.LoginService.CreatingCookieEventArgs/vb/Global.asax#2)]
]]></format>
</remarks>
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/bb386582(v=vs.100)">Windows Communication Foundation Authentication Service Overview</related>
</Docs>
<Members>
<Member MemberName="CookieIsSet">
<MemberSignature Language="C#" Value="public bool CookieIsSet { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool CookieIsSet" />
<MemberSignature Language="DocId" Value="P:System.Web.ApplicationServices.CreatingCookieEventArgs.CookieIsSet" />
<MemberSignature Language="VB.NET" Value="Public Property CookieIsSet As Boolean" />
<MemberSignature Language="F#" Value="member this.CookieIsSet : bool with get, set" Usage="System.Web.ApplicationServices.CreatingCookieEventArgs.CookieIsSet" />
<MemberSignature Language="C++ CLI" Value="public:
 property bool CookieIsSet { bool get(); void set(bool value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.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>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a value that indicates whether the authentication cookie has been created.</summary>
<value>
<see langword="true" /> if the authentication cookie was created; otherwise, <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.ApplicationServices.AuthenticationService> class checks the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.CookieIsSet%2A> property to determine whether the authentication cookie has been created. You set this value to `true` if you create an authentication cookie in an event handler for the <xref:System.Web.ApplicationServices.AuthenticationService.CreatingCookie> event. If <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.CookieIsSet%2A> is set to `false` (the default value), the <xref:System.Web.ApplicationServices.AuthenticationService> class creates an authentication cookie, This overwrites any cookie that you have created in the handler for the <xref:System.Web.ApplicationServices.AuthenticationService.CreatingCookie> event.
## Examples
The following example shows an event handler for the <xref:System.Web.ApplicationServices.AuthenticationService.CreatingCookie> event. The handler retrieves user values from the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs> object to customize the authentication cookie. The <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.CookieIsSet%2A> property is set to `true` after the authentication ticket is created.
[!code-csharp[System.Web.Security.LoginService.CreatingCookieEventArgs#2](~/snippets/csharp/VS_Snippets_WebNet/System.Web.Security.LoginService.CreatingCookieEventArgs/cs/Global.asax#2)]
[!code-vb[System.Web.Security.LoginService.CreatingCookieEventArgs#2](~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Security.LoginService.CreatingCookieEventArgs/vb/Global.asax#2)]
]]></format>
</remarks>
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/bb386582(v=vs.100)">Windows Communication Foundation Authentication Service Overview</related>
</Docs>
</Member>
<Member MemberName="CustomCredential">
<MemberSignature Language="C#" Value="public string CustomCredential { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string CustomCredential" />
<MemberSignature Language="DocId" Value="P:System.Web.ApplicationServices.CreatingCookieEventArgs.CustomCredential" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property CustomCredential As String" />
<MemberSignature Language="F#" Value="member this.CustomCredential : string" Usage="System.Web.ApplicationServices.CreatingCookieEventArgs.CustomCredential" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ CustomCredential { System::String ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.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 additional authentication values that are provided by the user.</summary>
<value>The custom values required for authentication, other than user name and password.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You use the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.CustomCredential%2A> property to retrieve custom values in the authentication ticket. The <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.CustomCredential%2A> property contains the value passed to the <xref:System.Web.ApplicationServices.AuthenticationService.Login%2A> method. Typically, this property is used to pass custom values that must be validated with the user name and password, such as an identification number. If more than one value is stored in the property, you must parse the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.CustomCredential%2A> property in order to retrieve values.
## Examples
The following example shows an event handler for the <xref:System.Web.ApplicationServices.AuthenticationService.CreatingCookie> event. The handler retrieves user values from the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs> object in order to customize the authentication cookie. The value passed in the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.CustomCredential%2A> property is stored in the <xref:System.Web.Security.FormsAuthenticationTicket.UserData%2A> property of the forms authentication ticket.
> [!NOTE]
> Store the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.CustomCredential%2A> property in a cookie only when you know that the data in the property is not sensitive. Malicious users can access the values in the cookie.
[!code-csharp[System.Web.Security.LoginService.CreatingCookieEventArgs#2](~/snippets/csharp/VS_Snippets_WebNet/System.Web.Security.LoginService.CreatingCookieEventArgs/cs/Global.asax#2)]
[!code-vb[System.Web.Security.LoginService.CreatingCookieEventArgs#2](~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Security.LoginService.CreatingCookieEventArgs/vb/Global.asax#2)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="IsPersistent">
<MemberSignature Language="C#" Value="public bool IsPersistent { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool IsPersistent" />
<MemberSignature Language="DocId" Value="P:System.Web.ApplicationServices.CreatingCookieEventArgs.IsPersistent" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property IsPersistent As Boolean" />
<MemberSignature Language="F#" Value="member this.IsPersistent : bool" Usage="System.Web.ApplicationServices.CreatingCookieEventArgs.IsPersistent" />
<MemberSignature Language="C++ CLI" Value="public:
 property bool IsPersistent { bool get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.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.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a value that indicates whether the authentication cookie should be retained beyond the current session.</summary>
<value>
<see langword="true" /> if the cookie should be retained beyond the current session; otherwise, <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When you create a <xref:System.Web.Security.FormsAuthenticationTicket> object, you can use the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.IsPersistent%2A> property to specify whether the authentication cookie is retained beyond the current session.
## Examples
The following example shows an event handler for the <xref:System.Web.ApplicationServices.AuthenticationService.CreatingCookie> event. The handler retrieves user values from the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs> object in order to customize the authentication cookie. The <xref:System.Web.Security.FormsAuthenticationTicket.IsPersistent%2A> property of the <xref:System.Web.Security.FormsAuthenticationTicket> object is set to the value in the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.IsPersistent%2A> property.
[!code-csharp[System.Web.Security.LoginService.CreatingCookieEventArgs#2](~/snippets/csharp/VS_Snippets_WebNet/System.Web.Security.LoginService.CreatingCookieEventArgs/cs/Global.asax#2)]
[!code-vb[System.Web.Security.LoginService.CreatingCookieEventArgs#2](~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Security.LoginService.CreatingCookieEventArgs/vb/Global.asax#2)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Password">
<MemberSignature Language="C#" Value="public string Password { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Password" />
<MemberSignature Language="DocId" Value="P:System.Web.ApplicationServices.CreatingCookieEventArgs.Password" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property Password As String" />
<MemberSignature Language="F#" Value="member this.Password : string" Usage="System.Web.ApplicationServices.CreatingCookieEventArgs.Password" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ Password { System::String ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.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 password for the user.</summary>
<value>The password that is provided by the user for authentication.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You use the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.Password%2A> property to retrieve the password when you set custom values in the authentication ticket.
> [!NOTE]
> Do not save the value of the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.Password%2A> property in the authentication ticket. A malicious user can access the cookie and retrieve the password even though the cookie is encrypted.
]]></format>
</remarks>
</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.ApplicationServices.CreatingCookieEventArgs.UserName" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property UserName As String" />
<MemberSignature Language="F#" Value="member this.UserName : string" Usage="System.Web.ApplicationServices.CreatingCookieEventArgs.UserName" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ UserName { System::String ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.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 name for the user.</summary>
<value>The name that is provided by the user for authentication.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You use the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.UserName%2A> property to retrieve the authentication name when you set custom values in the authentication ticket. Typically, you set the <xref:System.Web.Security.FormsAuthenticationTicket.Name%2A> property of the <xref:System.Web.Security.FormsAuthenticationTicket> object to the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.UserName%2A> value.
## Examples
The following example shows an event handler for the <xref:System.Web.ApplicationServices.AuthenticationService.CreatingCookie> event. The handler retrieves user values from the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs> object to customize the authentication cookie. The <xref:System.Web.Security.FormsAuthenticationTicket.Name%2A> property is set to the values of the <xref:System.Web.ApplicationServices.CreatingCookieEventArgs.UserName%2A> property.
[!code-csharp[System.Web.Security.LoginService.CreatingCookieEventArgs#2](~/snippets/csharp/VS_Snippets_WebNet/System.Web.Security.LoginService.CreatingCookieEventArgs/cs/Global.asax#2)]
[!code-vb[System.Web.Security.LoginService.CreatingCookieEventArgs#2](~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.Security.LoginService.CreatingCookieEventArgs/vb/Global.asax#2)]
]]></format>
</remarks>
</Docs>
</Member>
</Members>
</Type>