Definition
Assembly: CloudNimble.EasyAF.Http.dll Namespace: CloudNimble.EasyAF.Http Inheritance: System.ObjectSyntax
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 afterAddHttpContextAccessor 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
objectSyntax
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, ornull 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, ornull 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
objectSyntax
Parameters
Returns
Type:bool
Equals Inherited
Inherited from
objectSyntax
Parameters
Returns
Type:bool
GetHashCode Inherited Virtual
Inherited from
objectSyntax
Returns
Type:int
GetType Inherited
Inherited from
objectSyntax
Returns
Type:System.Type
MemberwiseClone Inherited
Inherited from
objectSyntax
Returns
Type:object
ReferenceEquals Inherited
Inherited from
objectSyntax
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
objectSyntax
Returns
Type:string?
Related APIs
- Microsoft.AspNetCore.Http.IHttpContextAccessor