Soenneker.Extensions.IHttpContextAccessors
4.0.144
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Extensions.IHttpContextAccessors --version 4.0.144
NuGet\Install-Package Soenneker.Extensions.IHttpContextAccessors -Version 4.0.144
<PackageReference Include="Soenneker.Extensions.IHttpContextAccessors" Version="4.0.144" />
<PackageVersion Include="Soenneker.Extensions.IHttpContextAccessors" Version="4.0.144" />
<PackageReference Include="Soenneker.Extensions.IHttpContextAccessors" />
paket add Soenneker.Extensions.IHttpContextAccessors --version 4.0.144
#r "nuget: Soenneker.Extensions.IHttpContextAccessors, 4.0.144"
#:package Soenneker.Extensions.IHttpContextAccessors@4.0.144
#addin nuget:?package=Soenneker.Extensions.IHttpContextAccessors&version=4.0.144
#tool nuget:?package=Soenneker.Extensions.IHttpContextAccessors&version=4.0.144
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.766)
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 |
|---|---|---|
| 11.0.155 | 0 | 10/27/2026 |
| 11.0.154 | 0 | 10/27/2026 |
| 11.0.153 | 44 | 10/26/2026 |
| 11.0.152 | 41 | 10/26/2026 |
| 11.0.151 | 82 | 10/26/2026 |
| 4.0.149 | 176 | 10/15/2026 |
| 4.0.148 | 96 | 10/15/2026 |
| 4.0.147 | 99 | 10/14/2026 |
| 4.0.145 | 89 | 10/14/2026 |
| 4.0.144 | 91 | 10/14/2026 |
| 4.0.138 | 95 | 10/12/2026 |
| 4.0.136 | 94 | 10/12/2026 |
| 4.0.135 | 95 | 10/12/2026 |
| 4.0.134 | 103 | 10/12/2026 |
| 4.0.133 | 105 | 10/11/2026 |
| 4.0.132 | 96 | 10/11/2026 |
| 4.0.131 | 170 | 9/30/2026 |
| 4.0.130 | 121 | 9/25/2026 |
| 4.0.129 | 107 | 9/25/2026 |
| 4.0.128 | 110 | 9/24/2026 |
Use NuGet API token for publishing