Esempio n. 1
0
        public static string GetUserIp(this HttpContext httpContext)
        {
#if NET40
            string userIp = httpContext.Request.UserHostAddress;
#else
            string userIp = Utils.SafeToString(httpContext.Connection.RemoteIpAddress);
#endif
            return(userIp);
        }
Esempio n. 2
0
        public static string GetUserIp(this HttpContext httpContext)
        {
#if NET452
            string userIp = httpContext.Request.UserHostAddress;
#else
            string userIp = Utils.SafeToString(httpContext.Connection.RemoteIpAddress);
#endif

            string xForwardedFor = httpContext.GetRequestHeader(Constants.HttpHeaderXForwardedFor);
            if (!string.IsNullOrEmpty(xForwardedFor))
            {
                userIp = xForwardedFor + ", " + userIp;
            }

            return(userIp);
        }