Soenneker.Extensions.IHttpContextAccessors
4.0.117
Prefix Reserved
dotnet add package Soenneker.Extensions.IHttpContextAccessors --version 4.0.117
NuGet\Install-Package Soenneker.Extensions.IHttpContextAccessors -Version 4.0.117
<PackageReference Include="Soenneker.Extensions.IHttpContextAccessors" Version="4.0.117" />
<PackageVersion Include="Soenneker.Extensions.IHttpContextAccessors" Version="4.0.117" />
<PackageReference Include="Soenneker.Extensions.IHttpContextAccessors" />
paket add Soenneker.Extensions.IHttpContextAccessors --version 4.0.117
#r "nuget: Soenneker.Extensions.IHttpContextAccessors, 4.0.117"
#:package Soenneker.Extensions.IHttpContextAccessors@4.0.117
#addin nuget:?package=Soenneker.Extensions.IHttpContextAccessors&version=4.0.117
#tool nuget:?package=Soenneker.Extensions.IHttpContextAccessors&version=4.0.117
Soenneker.Extensions.IHttpContextAccessors
Extension methods for retrieving common request and connection data through an injected IHttpContextAccessor.
Installation
dotnet add package Soenneker.Extensions.IHttpContextAccessors
Usage
Register the ASP.NET Core accessor once:
builder.Services.AddHttpContextAccessor();
Then read the address while an HTTP request is active:
using Soenneker.Extensions.IHttpContextAccessors;
string? clientIp = httpContextAccessor.GetRequestIp();
GetRequestIp() delegates to the companion HttpContext extension. It uses a valid CF-Connecting-IP address first, then a valid first address from X-Forwarded-For, then the connection's remote IP. Malformed header values are ignored. It returns null when there is no active HttpContext or no address can be found.
Forwarded headers are caller-controlled unless your proxy and ASP.NET Core forwarded-header configuration establish trust. Do not treat the returned text as authenticated identity by itself.
IHttpContextAccessor.HttpContext is request-flow state. Call this extension when the value is needed; do not capture the HttpContext for later background work. If a background operation needs the address, copy the returned string into the work item while handling the request.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Soenneker.Extensions.HttpContext (>= 4.0.738)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.117 | 0 | 9/8/2026 |
| 4.0.116 | 0 | 9/8/2026 |
| 4.0.115 | 20 | 9/7/2026 |
| 4.0.114 | 31 | 9/7/2026 |
| 4.0.113 | 90 | 9/5/2026 |
| 4.0.112 | 71 | 9/4/2026 |
| 4.0.111 | 90 | 8/31/2026 |
| 4.0.110 | 78 | 8/31/2026 |
| 4.0.109 | 82 | 8/31/2026 |
| 4.0.108 | 94 | 8/30/2026 |
| 4.0.107 | 94 | 8/30/2026 |
| 4.0.106 | 91 | 8/30/2026 |
| 4.0.105 | 86 | 8/29/2026 |
| 4.0.103 | 90 | 8/29/2026 |
| 4.0.102 | 118 | 8/26/2026 |
| 4.0.101 | 92 | 8/26/2026 |
| 4.0.100 | 99 | 8/21/2026 |
| 4.0.99 | 128 | 8/19/2026 |
| 4.0.98 | 120 | 8/18/2026 |
| 4.0.97 | 153 | 8/12/2026 |
Updated Soenneker.Extensions.HttpContext to 4.0.738