Set dummy IP address in integration test with Asp.Net Core TestServer
You can write middleware to set custom IP Address since this property is writable: public class FakeRemoteIpAddressMiddleware { private readonly RequestDelegate next; private readonly IPAddress fakeIpAddress = IPAddress.Parse(“127.168.1.32”); public FakeRemoteIpAddressMiddleware(RequestDelegate next) { this.next = next; } public async Task Invoke(HttpContext httpContext) { httpContext.Connection.RemoteIpAddress = fakeIpAddress; await this.next(httpContext); } } Then you can create StartupStub class … Read more