28 Kasım 2015 Cumartesi

c# proxy arkasındaki ip

public static string GetUserIP() {  
    var ip = ( HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null
              && HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != "" )
             ? HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]
             : HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
    if (ip.Contains( "," ))
        ip = ip.Split( ',' ).First().Trim();
    return ip;
}