| 導購 | 订阅 | 在线投稿
分享
 
 
 

c#獲取真實IP和代理IP

2008-12-13 08:24:18  編輯來源:互聯網  简体版  手機版  評論  字體: ||
 
  獲取真實IPview plaincopy to clipboardprint?
  public static string GetRealIP()
  {
  string ip;
  try
  {
  HttpRequest request = HttpContext.Current.Request;
  
  if (request.ServerVariables["HTTP_VIA"] != null)
  {
  ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim();
  }
  else
  {
  ip = request.UserHostAddress;
  }
  }
  catch (Exception e)
  {
  throw e;
  }
  
  return ip;
  }
  public static string GetRealIP()
  {
  string ip;
  try
  {
  HttpRequest request = HttpContext.Current.Request;
  if (request.ServerVariables["HTTP_VIA"] != null)
  {
  ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim();
  }
  else
  {
  ip = request.UserHostAddress;
  }
  }
  catch (Exception e)
  {
  throw e;
  }
  return ip;
  }獲取代理IPview plaincopy to clipboardprint?
  public static string GetViaIP()
  {
  string viaIp = null;
  
  try
  {
  HttpRequest request = HttpContext.Current.Request;
  
  if (request.ServerVariables["HTTP_VIA"] != null)
  {
  viaIp = request.UserHostAddress;
  }
  
  }
  catch (Exception e)
  {
  
  throw e;
  }
  
  return viaIp;
 
獲取真實IPview plaincopy to clipboardprint? public static string GetRealIP() { string ip; try { HttpRequest request = HttpContext.Current.Request; if (request.ServerVariables["HTTP_VIA"] != null) { ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim(); } else { ip = request.UserHostAddress; } } catch (Exception e) { throw e; } return ip; } public static string GetRealIP() { string ip; try { HttpRequest request = HttpContext.Current.Request; if (request.ServerVariables["HTTP_VIA"] != null) { ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim(); } else { ip = request.UserHostAddress; } } catch (Exception e) { throw e; } return ip; }獲取代理IPview plaincopy to clipboardprint? public static string GetViaIP() { string viaIp = null; try { HttpRequest request = HttpContext.Current.Request; if (request.ServerVariables["HTTP_VIA"] != null) { viaIp = request.UserHostAddress; } } catch (Exception e) { throw e; } return viaIp;
󰈣󰈤
 
 
 
>>返回首頁<<
 
 
 
 
 熱帖排行
 
王朝網路微信公眾號
微信掃碼關註本站公眾號 wangchaonetcn
 
  免責聲明:本文僅代表作者個人觀點,與王朝網絡無關。王朝網絡登載此文出於傳遞更多信息之目的,並不意味著贊同其觀點或證實其描述,其原創性以及文中陳述文字和內容未經本站證實,對本文以及其中全部或者部分內容、文字的真實性、完整性、及時性本站不作任何保證或承諾,請讀者僅作參考,並請自行核實相關內容。
 
© 2005- 王朝網路 版權所有