I'm using Owin.Testing as test env. In my controller i need to get remote ip address from the caller.
//in my controller method
var ip = GetIp(Request);
Util
private string GetIp(HttpRequestMessage request)
{
return request.Properties.ContainsKey("MS_HttpContext")
? (request.Properties["MS_HttpContext"] as HttpContextWrapper)?.Request?.UserHostAddress
: request.GetOwinContext()?.Request?.RemoteIpAddress;
}
As a result Properties does not contains MS_HttpContext and RemoteIpAddress of OwinContext is null.
Is there any option to get IP?