Guest User

Untitled

a guest
Jul 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. private static readonly string[] _ipHeaderOrder = new[] { "HTTP_X_FORWARDED_FOR", "HTTP_X_CLUSTER_CLIENT_IP", "REMOTE_ADDR" };
  2.  
  3. public static string ClientAddress(this HttpRequest request)
  4. {
  5. foreach (string header in _ipHeaderOrder)
  6. {
  7. string ipAddress = request.ServerVariables[header];
  8. if (ipAddress != null)
  9. {
  10. return ipAddress;
  11. }
  12. }
  13. return string.Empty;
  14. }
Add Comment
Please, Sign In to add comment