1
Ich benutze Owin.Testing als Test env. In meinem Controller muss ich Remote-IP-Adresse vom Anrufer erhalten.Erhalten Sie Remote-IP bei der Verwendung von Owin.Testing
//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;
}
Als Ergebnis Eigenschaften nicht enthält MS_HttpContext und RemoteIP von OwinContext null ist.
Gibt es eine Option, um IP zu bekommen?