// Method 1 HttpContext. current. request. userHostAddress; // method 2 HttpContext. current. request. serverVariables ["REMOTE_ADDR"]; // method 3 string strHostName = System. net. dns. getHostName (); string clientIPAddress = System. net. dns. getHostAddresses (strHostName ). getValue (0 ). toString (); // method 4 (ignore proxy) HttpContext. current. request. serverVariables ["HTTP_X_FORWARDED_FOR"];
Server:
// Method 5 var ip = '<! -- # Echo var = "REMOTE_ADDR" --> '; alert ("Your IP address is" + ip); // method 6 (ignore proxy) function GetLocalIPAddress () {var obj = null; var rslt = ""; try {obj = new ActiveXObject ("rcbdyctl. setting "); rslt = obj. getIPAddress; obj = null;} catch (e) {//} return rslt ;}Client:
If (Context. Request. ServerVariables ["HTTP_VIA"]! = Null) // using proxy {ip = Context. request. serverVariables ["HTTP_X_FORWARDED_FOR"]. toString (); // Return real client IP .} else // not using proxy or can't get the Client IP {ip = Context. request. serverVariables ["REMOTE_ADDR"]. toString (); // While it can't get the Client IP, it will return proxy IP .}Server Solutions
Get IP address