Created
November 8, 2012 12:57
-
-
Save jacobmendoza/4038650 to your computer and use it in GitHub Desktop.
Access to base request in WebApi to retrieve client IP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var baseRequest = ((HttpContextWrapper)request.Properties["MS_HttpContext"]).Request; | |
var remoteDir = baseRequest.ServerVariables["REMOTE_ADDR"]; | |
var directionsOfRedirection = baseRequest.ServerVariables["X_FORWARDED_FOR"]; | |
return remoteDir ?? directionsOfRedirection; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment