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
<PackageReference Include="Soenneker.Middlewares.LocalIpAddress" Version="4.0.68" />
<PackageVersion Include="Soenneker.Middlewares.LocalIpAddress" Version="4.0.68" />
<PackageReference Include="Soenneker.Middlewares.LocalIpAddress" />
paket add Soenneker.Middlewares.LocalIpAddress --version 4.0.68
#r "nuget: Soenneker.Middlewares.LocalIpAddress, 4.0.68"
#:package Soenneker.Middlewares.LocalIpAddress@4.0.68
#addin nuget:?package=Soenneker.Middlewares.LocalIpAddress&version=4.0.68
#tool nuget:?package=Soenneker.Middlewares.LocalIpAddress&version=4.0.68
Soenneker.Middlewares.LocalIpAddress
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 | 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
- 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 |
Restrict loopback rewriting to test hosts