HttpResponse.ClientDisconnectedToken Property

.NET Framework 4.5

Gets a CancellationToken object that is tripped when the client disconnects.

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)

public CancellationToken ClientDisconnectedToken { get; }

Property Value

Type: System.Threading.CancellationToken
The cancellation token.

This API is thread-safe. However, there are some restrictions on how the cancellation token should be used. Using it incorrectly can lead to race conditions, deadlocks, or other unexpected behavior. Keep in mind the following guidelines:

  • Ensure that you don't call into this API outside the bounds of a single request, because ASP.NET will dispose of the cancellation token at the end of the request. There is no guarantee that the token will ever transition to a canceled state before it is disposed. For example, if the request finishes without the client having disconnected, the token will be disposed without having first been canceled.

  • Do not wait on the CancellationToken.WaitHandle, as this defeats the purpose of an async notification and can cause deadlocks.

  • Do not call the. CancellationToken.Register overloads which invoke the callback on the original SynchronizationContext object.

  • Do not use the HttpContext object or other non-thread-safe ASP.NET intrinsic objects from within the callback provided to the CancellationToken.Register method. The callback may be running concurrently with other ASP.NET or application code.

  • Keep the callback methods short-running and non-blocking.

  • Make every effort to avoid throwing exceptions from within the callback methods.

This property is only applicable to Internet Information Service (IIS) 7.5 in integrated mode. If you invoke it without the right IIS version or pipeline mode, a PlatformNotSupportedException is thrown. To determine the IIS version, use IISVersion. To determine the pipeline mode, use UsingIntegratedPipeline.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft