title: Get ip access web api 2
body: <p>I am trying to get an IP client in my AuthorizationFilterAttribute but only get the IP: 192.168.0.1. How to fix it?</p>
  
  <pre><code>public override void OnAuthorization(HttpActionContext actionContext)
  {
      var ip = actionContext.Request.GetClientIpAddress();
      // Only get the IP: 192.168.0.1
  }
  
  public static string GetClientIpAddress(this HttpRequestMessage request)
  {
      if (request.Properties.ContainsKey(HttpContext))
      {
          dynamic ctx = request.Properties[HttpContext];
          if (ctx != null)
          {
              return ctx.Request.UserHostAddress;
          }
      }
      if (request.Properties.ContainsKey(RemoteEndpointMessage))
      {
          dynamic remoteEndpoint = request.Properties[RemoteEndpointMessage];
          if (remoteEndpoint != null)
          {
              return remoteEndpoint.Address;
          }
      }
      if (request.Properties.ContainsKey(OwinContext))
      {
          dynamic ctx = request.Properties[OwinContext];
          if (ctx != null)
          {
              return ctx.Request.RemoteIpAddress;
          }
      }
      return null;
  }
  </code></pre>