Soenneker.Extensions.IHttpContextAccessors 11.0.155

Prefix Reserved
dotnet add package Soenneker.Extensions.IHttpContextAccessors --version 11.0.155
                    
NuGet\Install-Package Soenneker.Extensions.IHttpContextAccessors -Version 11.0.155
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Extensions.IHttpContextAccessors" Version="11.0.155" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Extensions.IHttpContextAccessors" Version="11.0.155" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Extensions.IHttpContextAccessors" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Extensions.IHttpContextAccessors --version 11.0.155
                    
#r "nuget: Soenneker.Extensions.IHttpContextAccessors, 11.0.155"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Extensions.IHttpContextAccessors@11.0.155
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Extensions.IHttpContextAccessors&version=11.0.155
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.IHttpContextAccessors&version=11.0.155
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image 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 Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 60 10/27/2026
11.0.154 45 10/27/2026
11.0.153 63 10/26/2026
11.0.152 48 10/26/2026
11.0.151 89 10/26/2026
4.0.149 177 10/15/2026
4.0.148 98 10/15/2026
4.0.147 101 10/14/2026
4.0.145 91 10/14/2026
4.0.144 95 10/14/2026
4.0.138 97 10/12/2026
4.0.136 96 10/12/2026
4.0.135 97 10/12/2026
4.0.134 106 10/12/2026
4.0.133 106 10/11/2026
4.0.132 100 10/11/2026
4.0.131 170 9/30/2026
4.0.130 123 9/25/2026
4.0.129 110 9/25/2026
4.0.128 112 9/24/2026
Loading failed

Updated Soenneker.Extensions.HttpContext to 11.0.780