HttpContext.AllowAsyncDuringSyncStages HttpContext.AllowAsyncDuringSyncStages HttpContext.AllowAsyncDuringSyncStages HttpContext.AllowAsyncDuringSyncStages Property

Definition

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

public:
 property bool AllowAsyncDuringSyncStages { bool get(); void set(bool value); };
public bool AllowAsyncDuringSyncStages { get; set; }
member this.AllowAsyncDuringSyncStages : bool with get, set
Public Property AllowAsyncDuringSyncStages As Boolean

Property Value

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.

Remarks

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.

Applies to