|
|
@@ -460,17 +460,24 @@ namespace CallCenter.Utility
|
|
460
|
460
|
/// <returns>当前页面客户端的IP</returns>
|
|
461
|
461
|
public static string GetIP()
|
|
462
|
462
|
{
|
|
463
|
|
- string result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
|
|
464
|
|
- if (string.IsNullOrEmpty(result))
|
|
465
|
|
- result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
|
|
|
463
|
+ try
|
|
|
464
|
+ {
|
|
|
465
|
+ string result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
|
|
|
466
|
+ if (string.IsNullOrEmpty(result))
|
|
|
467
|
+ result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
|
|
466
|
468
|
|
|
467
|
|
- if (string.IsNullOrEmpty(result))
|
|
468
|
|
- result = HttpContext.Current.Request.UserHostAddress;
|
|
|
469
|
+ if (string.IsNullOrEmpty(result))
|
|
|
470
|
+ result = HttpContext.Current.Request.UserHostAddress;
|
|
469
|
471
|
|
|
470
|
|
- if (string.IsNullOrEmpty(result) || !ValidateString.IsIP(result))
|
|
471
|
|
- return "127.0.0.1";
|
|
|
472
|
+ if (string.IsNullOrEmpty(result) || !ValidateString.IsIP(result))
|
|
|
473
|
+ return "127.0.0.1";
|
|
472
|
474
|
|
|
473
|
|
- return result;
|
|
|
475
|
+ return result;
|
|
|
476
|
+ }
|
|
|
477
|
+ catch
|
|
|
478
|
+ {
|
|
|
479
|
+ return "127.0.0.1";
|
|
|
480
|
+ }
|
|
474
|
481
|
}
|
|
475
|
482
|
|
|
476
|
483
|
/// <summary>
|