Share via


IHttpContextAccessor Interface

Definition

Provides access to the current HttpContext, if one is available.

public interface class IHttpContextAccessor
public interface IHttpContextAccessor
type IHttpContextAccessor = interface
Public Interface IHttpContextAccessor
Derived

Remarks

This interface should be used with caution. It relies on AsyncLocal<T> which can have a negative performance impact on async calls. It also creates a dependency on "ambient state" which can make testing more difficult.

Properties

HttpContext

Gets or sets the current HttpContext. Returns null if there is no active HttpContext.

Applies to