Skip to main content

Definition

Assembly: CloudNimble.EasyAF.Http.dll Namespace: CloudNimble.EasyAF.Http Inheritance: System.Object

Syntax

Summary

IHttpContextAccessor that keeps an outer request and an inner in-process request as two contexts. DualHttpContextAccessor.HttpContext always returns DualHttpContextAccessor.Active. HttpContext) / DualHttpContextAccessor.End change which context is active without using Microsoft’s HttpContextAccessor setter (that setter nulls a shared holder and ends the outer request).

Remarks

Register this as IHttpContextAccessor after AddHttpContextAccessor so last-wins DI gives the rest of the pipeline this instance. Host Initialize assigns DualHttpContextAccessor.HttpContext (sets DualHttpContextAccessor.Outer and DualHttpContextAccessor.Active). Inner execute calls HttpContext), then DualHttpContextAccessor.End in finally. Host Dispose assigns null, which poisons the holder so every execution context sees request-end.

Examples

Constructors

.ctor

Syntax

.ctor Inherited

Inherited from object

Syntax

Properties

Active

Gets the context DualHttpContextAccessor.HttpContext returns. HttpContext) and DualHttpContextAccessor.End change this without using the setter.

Syntax

Property Value

Type: Microsoft.AspNetCore.Http.HttpContext

HttpContext

Syntax

Property Value

Type: Microsoft.AspNetCore.Http.HttpContext

Inner

Gets the inner in-process context, or null if HttpContext) has not run or DualHttpContextAccessor.End / request-end has already cleared it.

Syntax

Property Value

Type: Microsoft.AspNetCore.Http.HttpContext

Outer

Gets the incoming (outer) context, or null if the host has not assigned DualHttpContextAccessor.HttpContext yet.

Syntax

Property Value

Type: Microsoft.AspNetCore.Http.HttpContext

Methods

End

Makes DualHttpContextAccessor.HttpContext return DualHttpContextAccessor.Outer again and clears DualHttpContextAccessor.Inner. Does not write to DualHttpContextAccessor.Outer’s response.

Syntax

Equals Inherited Virtual

Inherited from object

Syntax

Parameters

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

Parameters

Returns

Type: bool

Start

Makes DualHttpContextAccessor.HttpContext return inner without dropping DualHttpContextAccessor.Outer. Do not use the DualHttpContextAccessor.HttpContext setter for this.

Syntax

Parameters

Exceptions

ToString Inherited Virtual

Inherited from object

Syntax

Returns

Type: string?
  • Microsoft.AspNetCore.Http.IHttpContextAccessor