How to get the IP address of Client Using Javascript

sreekanth  picture sreekanth · Jan 12, 2011 · Viewed 19.4k times · Source

Hi Please let me know how can i get the client IP address. I have used the following .

Ip = <--#echo var="REMOTE_ADDR"-->;

ip = '<%= Request.UserHostAddress>';

But these are not working.

Answer

Usman Malik picture Usman Malik · Jul 28, 2011

Use the following code for to get the IP Address in ASP Classic

<%
Dim UserIPAddress
UserIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If UserIPAddress = "" Then
UserIPAddress = Request.ServerVariables("REMOTE_ADDR")
End If
%>