/
SessionStateUtility.xml
359 lines (316 loc) · 29.3 KB
/
SessionStateUtility.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
<Type Name="SessionStateUtility" FullName="System.Web.SessionState.SessionStateUtility">
<TypeSignature Language="C#" Value="public static class SessionStateUtility" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract sealed beforefieldinit SessionStateUtility extends System.Object" />
<TypeSignature Language="DocId" Value="T:System.Web.SessionState.SessionStateUtility" />
<TypeSignature Language="VB.NET" Value="Public Class SessionStateUtility" />
<TypeSignature Language="F#" Value="type SessionStateUtility = class" />
<TypeSignature Language="C++ CLI" Value="public ref class SessionStateUtility abstract sealed" />
<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 />
<Docs>
<summary>Provides helper methods used by session-state modules and session-state store providers to manage session information for an ASP.NET application. This class cannot be inherited.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.SessionState.SessionStateUtility> class provides static helper methods that are used by a session-state module or a session-state store provider. Application developers will not need to call these methods from their code.
The following table describes the ways the session-state module and session-state store provider use the methods.
|Method|Use|
|------------|---------|
|<xref:System.Web.SessionState.SessionStateUtility.GetHttpSessionStateFromContext%2A> method|Can be used by custom session-state modules to either retrieve session information for an existing session or create session information for a new session.|
|<xref:System.Web.SessionState.SessionStateUtility.AddHttpSessionStateToContext%2A> method|Called by the session-state module to add the session data to the current <xref:System.Web.HttpContext> and make it available to application code through the <xref:System.Web.HttpContext.Session%2A> property.|
|<xref:System.Web.SessionState.SessionStateUtility.RemoveHttpSessionStateFromContext%2A> method|Called by the session-state module during the <xref:System.Web.HttpApplication.ReleaseRequestState> or <xref:System.Web.HttpApplication.EndRequest> events at the end of a request, to clear session data from the current <xref:System.Web.HttpContext>.|
|<xref:System.Web.SessionState.SessionStateUtility.GetSessionStaticObjects%2A> method|Called by the session-state module to get a reference to the <xref:System.Web.SessionState.HttpSessionState.StaticObjects%2A> collection based on objects defined in the Global.asax file. The <xref:System.Web.HttpStaticObjectsCollection> collection returned is included with the session data added to the current <xref:System.Web.HttpContext>.|
Session data is passed to and retrieved from the current <xref:System.Web.HttpContext> as an <xref:System.Web.SessionState.HttpSessionStateContainer> object or any valid implementation of the <xref:System.Web.SessionState.IHttpSessionState> interface.
For information about implementing a session-state store provider, see [Implementing a Session-State Store Provider](https://docs.microsoft.com/previous-versions/aspnet/ms178587(v=vs.100)).
## Examples
The following code example shows a custom session-state module implementation that stores session information in memory using a <xref:System.Collections.Hashtable>. The module uses the <xref:System.Web.SessionState.SessionStateUtility> class to reference the current <xref:System.Web.HttpContext> and <xref:System.Web.SessionState.SessionIDManager>, retrieve the current <xref:System.Web.HttpStaticObjectsCollection>, and raise the **Session_OnEnd** event defined in the Global.asax file for the ASP.NET application. This application does not prevent simultaneous Web requests from using the same session identifier.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.SessionState.SessionStateUtility/CS/mysessionstatemodule.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.SessionState.SessionStateUtility/VB/mysessionstatemodule.vb" id="Snippet1":::
To use this custom session-state module in an ASP.NET application, you can replace the existing <xref:System.Web.SessionState.SessionStateModule> reference in the Web.config file, as shown in the following example.
```
<configuration>
<system.web>
<httpModules>
<remove name="Session" />
<add name="Session"
type="Samples.AspNet.SessionState.MySessionStateModule" />
</httpModules>
</system.web>
</configuration>
```
]]></format>
</remarks>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms178581(v=vs.100)">ASP.NET Session State Overview</related>
</Docs>
<Members>
<Member MemberName="AddHttpSessionStateToContext">
<MemberSignature Language="C#" Value="public static void AddHttpSessionStateToContext (System.Web.HttpContext context, System.Web.SessionState.IHttpSessionState container);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void AddHttpSessionStateToContext(class System.Web.HttpContext context, class System.Web.SessionState.IHttpSessionState container) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.SessionState.SessionStateUtility.AddHttpSessionStateToContext(System.Web.HttpContext,System.Web.SessionState.IHttpSessionState)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub AddHttpSessionStateToContext (context As HttpContext, container As IHttpSessionState)" />
<MemberSignature Language="F#" Value="static member AddHttpSessionStateToContext : System.Web.HttpContext * System.Web.SessionState.IHttpSessionState -> unit" Usage="System.Web.SessionState.SessionStateUtility.AddHttpSessionStateToContext (context, container)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void AddHttpSessionStateToContext(System::Web::HttpContext ^ context, System::Web::SessionState::IHttpSessionState ^ container);" />
<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="context" Type="System.Web.HttpContext" />
<Parameter Name="container" Type="System.Web.SessionState.IHttpSessionState" />
</Parameters>
<Docs>
<param name="context">The <see cref="T:System.Web.HttpContext" /> object to which to add the <see cref="T:System.Web.SessionState.HttpSessionState" /> object.</param>
<param name="container">The <see cref="T:System.Web.SessionState.IHttpSessionState" /> implementation instance to add to the specified HTTP context.</param>
<summary>Applies the session data to the context for the current request.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.SessionState.SessionStateUtility.AddHttpSessionStateToContext%2A> method is used by a session-state module to apply session data to the current request. This occurs during the <xref:System.Web.HttpApplication.AcquireRequestState> event at the beginning of a request. Session data for the current request is either retrieved for an existing session or created for a new session. The session data is then encapsulated in an <xref:System.Web.SessionState.IHttpSessionState> implementation instance, which is passed to the <xref:System.Web.SessionState.SessionStateUtility.AddHttpSessionStateToContext%2A> method along with the current <xref:System.Web.HttpContext>. The supplied session data is then made available to application code through the <xref:System.Web.HttpContext.Session%2A> property of the current context.
## Examples
The following code example shows the handler for the <xref:System.Web.HttpApplication.AcquireRequestState> event in a custom session-state module. The custom module retrieves existing session information or creates new session information and uses the <xref:System.Web.SessionState.SessionStateUtility.AddHttpSessionStateToContext%2A> method to add it to the <xref:System.Web.HttpContext> of the current request. This code example is part of a larger example provided for the <xref:System.Web.SessionState.SessionStateUtility> class.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.SessionState.SessionStateUtility/CS/mysessionstatemodule.cs" id="Snippet4":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.SessionState.SessionStateUtility/VB/mysessionstatemodule.vb" id="Snippet4":::
]]></format>
</remarks>
<exception cref="T:System.Web.HttpException">An <see cref="T:System.Web.SessionState.HttpSessionState" /> object for the current session has already been added to the specified <paramref name="context" />.</exception>
</Docs>
</Member>
<Member MemberName="GetHttpSessionStateFromContext">
<MemberSignature Language="C#" Value="public static System.Web.SessionState.IHttpSessionState GetHttpSessionStateFromContext (System.Web.HttpContext context);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Web.SessionState.IHttpSessionState GetHttpSessionStateFromContext(class System.Web.HttpContext context) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.SessionState.SessionStateUtility.GetHttpSessionStateFromContext(System.Web.HttpContext)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetHttpSessionStateFromContext (context As HttpContext) As IHttpSessionState" />
<MemberSignature Language="F#" Value="static member GetHttpSessionStateFromContext : System.Web.HttpContext -> System.Web.SessionState.IHttpSessionState" Usage="System.Web.SessionState.SessionStateUtility.GetHttpSessionStateFromContext context" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Web::SessionState::IHttpSessionState ^ GetHttpSessionStateFromContext(System::Web::HttpContext ^ context);" />
<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.SessionState.IHttpSessionState</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="context" Type="System.Web.HttpContext" />
</Parameters>
<Docs>
<param name="context">The <see cref="T:System.Web.HttpContext" /> from which to retrieve session data.</param>
<summary>Retrieves session data from the context for the current request.</summary>
<returns>An <see cref="T:System.Web.SessionState.IHttpSessionState" /> implementation instance populated with session data from the current request.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.SessionState.SessionStateUtility.GetHttpSessionStateFromContext%2A> method can be used by a session-state module to retrieve session data from the current request. This occurs during the <xref:System.Web.HttpApplication.ReleaseRequestState> event at the end of a request. The returned session data can then be written to the session data store. If the session has been abandoned, the session data can be removed from the data store and <xref:System.Web.HttpContext>, and the **Session_OnEnd** event can be executed.
## Examples
The following code example shows the handler for the <xref:System.Web.HttpApplication.ReleaseRequestState> event in a custom session-state module. The module retrieves session data from the <xref:System.Web.HttpContext> for the current request using the <xref:System.Web.SessionState.SessionStateUtility.GetHttpSessionStateFromContext%2A> method. This code example is part of a larger example provided for the <xref:System.Web.SessionState.SessionStateUtility> class.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.SessionState.SessionStateUtility/CS/mysessionstatemodule.cs" id="Snippet5":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.SessionState.SessionStateUtility/VB/mysessionstatemodule.vb" id="Snippet5":::
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>You can use the <see cref="M:System.Web.SessionState.SessionStateUtility.RemoveHttpSessionStateFromContext(System.Web.HttpContext)" /> method to remove session data from the internal store, and the <see cref="M:System.Web.SessionState.SessionStateUtility.RaiseSessionEnd(System.Web.SessionState.IHttpSessionState,System.Object,System.EventArgs)" /> method to raise the <see langword="Session_OnEnd" /> event.</para>
</block>
</Docs>
</Member>
<Member MemberName="GetSessionStaticObjects">
<MemberSignature Language="C#" Value="public static System.Web.HttpStaticObjectsCollection GetSessionStaticObjects (System.Web.HttpContext context);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Web.HttpStaticObjectsCollection GetSessionStaticObjects(class System.Web.HttpContext context) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.SessionState.SessionStateUtility.GetSessionStaticObjects(System.Web.HttpContext)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetSessionStaticObjects (context As HttpContext) As HttpStaticObjectsCollection" />
<MemberSignature Language="F#" Value="static member GetSessionStaticObjects : System.Web.HttpContext -> System.Web.HttpStaticObjectsCollection" Usage="System.Web.SessionState.SessionStateUtility.GetSessionStaticObjects context" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Web::HttpStaticObjectsCollection ^ GetSessionStaticObjects(System::Web::HttpContext ^ context);" />
<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.HttpStaticObjectsCollection</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="context" Type="System.Web.HttpContext" />
</Parameters>
<Docs>
<param name="context">The <see cref="T:System.Web.HttpContext" /> from which to get the static objects collection.</param>
<summary>Gets a reference to the static objects collection for the specified context.</summary>
<returns>An <see cref="T:System.Web.HttpStaticObjectsCollection" /> collection populated with the <see cref="P:System.Web.SessionState.HttpSessionState.StaticObjects" /> property value for the specified <see cref="T:System.Web.HttpContext" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.SessionState.SessionStateUtility.GetSessionStaticObjects%2A> method is used to retrieve the collection of static objects defined in the Global.asax file for the ASP.NET application. A session-state module implementation will supply the returned <xref:System.Web.HttpStaticObjectsCollection> collection to the <xref:System.Web.SessionState.IHttpSessionState> implementation instance that is added to the current context using the <xref:System.Web.SessionState.SessionStateUtility.AddHttpSessionStateToContext%2A> method.
A <xref:System.Web.SessionState.SessionStateStoreProviderBase> can also use the <xref:System.Web.SessionState.SessionStateUtility.GetSessionStaticObjects%2A> method when creating a <xref:System.Web.SessionState.SessionStateStoreData> object.
## Examples
The following code example shows the handler for the <xref:System.Web.HttpApplication.AcquireRequestState> event in a custom session-state module. The module retrieves existing session information or creates new session information, including the <xref:System.Web.HttpStaticObjectsCollection> collection returned from the <xref:System.Web.SessionState.SessionStateUtility.GetSessionStaticObjects%2A> method, and adds it to the <xref:System.Web.HttpContext> of the current request. This code example is part of a larger example provided for the <xref:System.Web.SessionState.SessionStateUtility> class.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.SessionState.SessionStateUtility/CS/mysessionstatemodule.cs" id="Snippet4":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.SessionState.SessionStateUtility/VB/mysessionstatemodule.vb" id="Snippet4":::
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="IsSessionStateReadOnly">
<MemberSignature Language="C#" Value="public static bool IsSessionStateReadOnly (System.Web.HttpContext context);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig bool IsSessionStateReadOnly(class System.Web.HttpContext context) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.SessionState.SessionStateUtility.IsSessionStateReadOnly(System.Web.HttpContext)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function IsSessionStateReadOnly (context As HttpContext) As Boolean" />
<MemberSignature Language="F#" Value="static member IsSessionStateReadOnly : System.Web.HttpContext -> bool" Usage="System.Web.SessionState.SessionStateUtility.IsSessionStateReadOnly context" />
<MemberSignature Language="C++ CLI" Value="public:
 static bool IsSessionStateReadOnly(System::Web::HttpContext ^ context);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="context" Type="System.Web.HttpContext" Index="0" FrameworkAlternate="netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1" />
</Parameters>
<Docs>
<param name="context">Specifies the <see cref="T:System.Web.HttpContext" /> to check.</param>
<summary>Gets a value which indicates whether the session state is read-only for the specified <see cref="T:System.Web.HttpContext" />.</summary>
<returns>
<see langword="true" /> if the session state is read-only; otherwise, <see langword="false" />.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="IsSessionStateRequired">
<MemberSignature Language="C#" Value="public static bool IsSessionStateRequired (System.Web.HttpContext context);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig bool IsSessionStateRequired(class System.Web.HttpContext context) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.SessionState.SessionStateUtility.IsSessionStateRequired(System.Web.HttpContext)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function IsSessionStateRequired (context As HttpContext) As Boolean" />
<MemberSignature Language="F#" Value="static member IsSessionStateRequired : System.Web.HttpContext -> bool" Usage="System.Web.SessionState.SessionStateUtility.IsSessionStateRequired context" />
<MemberSignature Language="C++ CLI" Value="public:
 static bool IsSessionStateRequired(System::Web::HttpContext ^ context);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="context" Type="System.Web.HttpContext" Index="0" FrameworkAlternate="netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1" />
</Parameters>
<Docs>
<param name="context">Specifies the <see cref="T:System.Web.HttpContext" /> to check.</param>
<summary>Gets a value which indicates whether the session state is required for the specified <see cref="T:System.Web.HttpContext" />.</summary>
<returns>
<see langword="true" /> if the session state is required; otherwise, <see langword="false" />.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="RaiseSessionEnd">
<MemberSignature Language="C#" Value="public static void RaiseSessionEnd (System.Web.SessionState.IHttpSessionState session, object eventSource, EventArgs eventArgs);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void RaiseSessionEnd(class System.Web.SessionState.IHttpSessionState session, object eventSource, class System.EventArgs eventArgs) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.SessionState.SessionStateUtility.RaiseSessionEnd(System.Web.SessionState.IHttpSessionState,System.Object,System.EventArgs)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub RaiseSessionEnd (session As IHttpSessionState, eventSource As Object, eventArgs As EventArgs)" />
<MemberSignature Language="F#" Value="static member RaiseSessionEnd : System.Web.SessionState.IHttpSessionState * obj * EventArgs -> unit" Usage="System.Web.SessionState.SessionStateUtility.RaiseSessionEnd (session, eventSource, eventArgs)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void RaiseSessionEnd(System::Web::SessionState::IHttpSessionState ^ session, System::Object ^ eventSource, EventArgs ^ eventArgs);" />
<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="session" Type="System.Web.SessionState.IHttpSessionState" />
<Parameter Name="eventSource" Type="System.Object" />
<Parameter Name="eventArgs" Type="System.EventArgs" />
</Parameters>
<Docs>
<param name="session">The <see cref="T:System.Web.SessionState.IHttpSessionState" /> implementation instance for the session that has ended.</param>
<param name="eventSource">The event source object to supply to the <see langword="Session_OnEnd" /> event.</param>
<param name="eventArgs">The <see cref="T:System.EventArgs" /> object to supply to the <see langword="Session_OnEnd" /> event.</param>
<summary>Executes the **Session_OnEnd** event defined in the Global.asax file for the ASP.NET application.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.SessionState.SessionStateUtility.RaiseSessionEnd%2A> method is used by a session-state module to execute the **Session_OnEnd** event defined in the Global.asax file for an ASP.NET application. A session-state module will call the <xref:System.Web.SessionState.SessionStateUtility.RaiseSessionEnd%2A> method when a session has been abandoned, or if the session expires.
## Examples
The following code example shows the handler for the <xref:System.Web.HttpApplication.ReleaseRequestState> event in a custom session-state module. If the session has been abandoned, the module executes the **Session_OnEnd** event defined in the Global.asax file for the application using the <xref:System.Web.SessionState.SessionStateUtility.RaiseSessionEnd%2A> method. This code example is part of a larger example provided for the <xref:System.Web.SessionState.SessionStateUtility> class.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.SessionState.SessionStateUtility/CS/mysessionstatemodule.cs" id="Snippet5":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.SessionState.SessionStateUtility/VB/mysessionstatemodule.vb" id="Snippet5":::
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="RemoveHttpSessionStateFromContext">
<MemberSignature Language="C#" Value="public static void RemoveHttpSessionStateFromContext (System.Web.HttpContext context);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void RemoveHttpSessionStateFromContext(class System.Web.HttpContext context) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.SessionState.SessionStateUtility.RemoveHttpSessionStateFromContext(System.Web.HttpContext)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub RemoveHttpSessionStateFromContext (context As HttpContext)" />
<MemberSignature Language="F#" Value="static member RemoveHttpSessionStateFromContext : System.Web.HttpContext -> unit" Usage="System.Web.SessionState.SessionStateUtility.RemoveHttpSessionStateFromContext context" />
<MemberSignature Language="C++ CLI" Value="public:
 static void RemoveHttpSessionStateFromContext(System::Web::HttpContext ^ context);" />
<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.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="context" Type="System.Web.HttpContext" />
</Parameters>
<Docs>
<param name="context">The <see cref="T:System.Web.HttpContext" /> from which to remove session data.</param>
<summary>Removes session data from the specified context.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.SessionState.SessionStateUtility.RemoveHttpSessionStateFromContext%2A> method clears session data from the specified <xref:System.Web.HttpContext>. A session-state module will call the <xref:System.Web.SessionState.SessionStateUtility.RemoveHttpSessionStateFromContext%2A> method in the handler for the <xref:System.Web.HttpApplication.ReleaseRequestState> event.
## Examples
The following code example shows the handler for the <xref:System.Web.HttpApplication.ReleaseRequestState> event in a custom session-state module. The event handler removes session data from the current <xref:System.Web.HttpContext>. This code example is part of a larger example provided for the <xref:System.Web.SessionState.SessionStateUtility> class.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.SessionState.SessionStateUtility/CS/mysessionstatemodule.cs" id="Snippet5":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.SessionState.SessionStateUtility/VB/mysessionstatemodule.vb" id="Snippet5":::
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="SerializationSurrogateSelector">
<MemberSignature Language="C#" Value="public static System.Runtime.Serialization.ISurrogateSelector SerializationSurrogateSelector { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property class System.Runtime.Serialization.ISurrogateSelector SerializationSurrogateSelector" />
<MemberSignature Language="DocId" Value="P:System.Web.SessionState.SessionStateUtility.SerializationSurrogateSelector" />
<MemberSignature Language="VB.NET" Value="Public Shared Property SerializationSurrogateSelector As ISurrogateSelector" />
<MemberSignature Language="F#" Value="static member SerializationSurrogateSelector : System.Runtime.Serialization.ISurrogateSelector with get, set" Usage="System.Web.SessionState.SessionStateUtility.SerializationSurrogateSelector" />
<MemberSignature Language="C++ CLI" Value="public:
 static property System::Runtime::Serialization::ISurrogateSelector ^ SerializationSurrogateSelector { System::Runtime::Serialization::ISurrogateSelector ^ get(); void set(System::Runtime::Serialization::ISurrogateSelector ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Runtime.Serialization.ISurrogateSelector</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a serialization surrogate selector that is used for session serialization customization.</summary>
<value>A serialization surrogate selector.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>