Soenneker.Middlewares.LocalIpAddress 4.0.68

Prefix Reserved
dotnet add package Soenneker.Middlewares.LocalIpAddress --version 4.0.68
                    
NuGet\Install-Package Soenneker.Middlewares.LocalIpAddress -Version 4.0.68
                    
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.Middlewares.LocalIpAddress" Version="4.0.68" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Middlewares.LocalIpAddress" Version="4.0.68" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Middlewares.LocalIpAddress" />
                    
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.Middlewares.LocalIpAddress --version 4.0.68
                    
#r "nuget: Soenneker.Middlewares.LocalIpAddress, 4.0.68"
                    
#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.Middlewares.LocalIpAddress@4.0.68
                    
#: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.Middlewares.LocalIpAddress&version=4.0.68
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Middlewares.LocalIpAddress&version=4.0.68
                    
Install as a Cake Tool

Soenneker.Middlewares.LocalIpAddress

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

Makes ASP.NET Core test requests appear to originate from IPv4 loopback by replacing both connection endpoint addresses with 127.0.0.1.

Installation

dotnet add package Soenneker.Middlewares.LocalIpAddress

Test-host usage

Set the test host environment to Testing through the test host or WebApplicationFactory configuration. In the application pipeline, add the middleware before anything that reads the connection IP:

using Soenneker.Middlewares.LocalIpAddress.Registrars;

app.UseForwardedHeaders();

if (app.Environment.IsEnvironment("Testing"))
    app.UseLocalIpAddress();

app.UseRateLimiter();
app.UseAuthorization();
app.MapControllers();

It may also run in the Development environment. Registration throws InvalidOperationException in every other environment.

Place it after forwarded-header processing; otherwise UseForwardedHeaders can overwrite the loopback value. Place it before authorization, rate limiting, auditing, or application code that reads Connection.RemoteIpAddress.

Security boundary

This middleware deliberately destroys the real network identity and can make an external request pass loopback-only policies. Use it only in an isolated development or test host. Do not change a deployed environment name to bypass the registration guard.

Both local and remote addresses are always IPv4 loopback. Ports and forwarded-header values are not changed.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Soenneker.Middlewares.LocalIpAddress:

Package Downloads
Soenneker.StartupFilters.IntegrationTests

A StartupFilter injecting middleware crucial to integration testing

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.68 150 8/30/2026
4.0.67 197 8/29/2026
4.0.66 120 8/29/2026
4.0.65 45 8/29/2026
4.0.64 1,805 7/27/2026
4.0.63 978 7/16/2026
4.0.62 1,507 6/18/2026
4.0.61 1,431 6/5/2026
4.0.60 117 6/5/2026
4.0.58 3,019 3/12/2026
4.0.57 146 3/12/2026
4.0.56 125 3/12/2026
4.0.55 199 3/12/2026
4.0.54 427 3/10/2026
4.0.53 430 3/9/2026
4.0.52 206 3/9/2026
4.0.51 127 3/9/2026
4.0.50 642 3/4/2026
4.0.49 2,669 1/2/2026
4.0.48 1,601 11/20/2025
Loading failed

Restrict loopback rewriting to test hosts