1
私はOwin.Testingをtest envとして使用しています。私のコントローラでは、私は発信者からリモートIPアドレスを取得する必要があります。結果のプロパティとしてOwin.Testingを使用してリモートIPを取得
//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;
}
OwinContextのMS_HttpContextとRemoteIpAddressがnullが含まれていません。
IPを取得するオプションはありますか?