HttpContext.AllowAsyncDuringSyncStages Property

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets or sets a value that indicates whether asynchronous operations are allowed during parts of ASP.NET request processing when they are not expected.

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

public bool AllowAsyncDuringSyncStages { get; set; }

Property Value

Type: System.Boolean

false if ASP.NET will throw an exception when the asynchronous API is used at a time when it is not expected; otherwise, true. The default value is false.

If this flag is not set to true, ASP.NET will throw an exception when it detects the application misusing the async API. This can occur if you try to call an asynchronous method during a part of the request processing pipeline where asynchronous operations are not expected, or if there is still outstanding asynchronous work when an asynchronous module or handler signals completion. This behavior is meant as a safety net to let you know early on if you're writing async code that doesn't fit expected patterns and might have negative side effects.

.NET Framework
Available since 4.5
Return to top