Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

interface Microsoft.​AspNetCore.​Http.​IHttpContextAccessor

Assembly: Microsoft.AspNetCore.Http.Abstractions

Provides access to the current <see cref="P:Microsoft.AspNetCore.Http.IHttpContextAccessor.HttpContext" /> , if one is available.

Remarks

This interface should be used with caution. It relies on <see cref="T:System.Threading.AsyncLocal`1" /> 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 <see cref="P:Microsoft.AspNetCore.Http.IHttpContextAccessor.HttpContext" /> . Returns <see langword="null" /> if there is no active <see cref="P:Microsoft.AspNetCore.Http.IHttpContextAccessor.HttpContext" /> .