Visitor IP address
-
Hi, How to get the visitor's actual IP address. I have tried all the possible solution like HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"], UserHostAddress, Remote_ADDR etc etc. But all are returning the same IP that is I think proxy ip. If we are behind the firewall/proxy then is there any way to get the local IP of the system like 100.100.100.27. Please confirm. Pankaj
-
Hi, How to get the visitor's actual IP address. I have tried all the possible solution like HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"], UserHostAddress, Remote_ADDR etc etc. But all are returning the same IP that is I think proxy ip. If we are behind the firewall/proxy then is there any way to get the local IP of the system like 100.100.100.27. Please confirm. Pankaj
-
Hi, How to get the visitor's actual IP address. I have tried all the possible solution like HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"], UserHostAddress, Remote_ADDR etc etc. But all are returning the same IP that is I think proxy ip. If we are behind the firewall/proxy then is there any way to get the local IP of the system like 100.100.100.27. Please confirm. Pankaj
The below given code gives you the IP address of the User Accessing the site: HttpContext.Current.Request.UserHostAddress; OR HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; To get the IP address of the machine and not the proxy use the following code: HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; I hope this was useful !!! :cool:
-
The below given code gives you the IP address of the User Accessing the site: HttpContext.Current.Request.UserHostAddress; OR HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; To get the IP address of the machine and not the proxy use the following code: HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; I hope this was useful !!! :cool:
I think he already mentioned these are not working for him. :(
Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Windows7 API Code Pack
Simplify Code Using NDepend
Basics of Bing Search API using .NET -
Hi, How to get the visitor's actual IP address. I have tried all the possible solution like HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"], UserHostAddress, Remote_ADDR etc etc. But all are returning the same IP that is I think proxy ip. If we are behind the firewall/proxy then is there any way to get the local IP of the system like 100.100.100.27. Please confirm. Pankaj
Hi pkp001, As pd69 said, HttpContext.Current.Request.UserHostAddress; this code will return the IP of the requested machine.
Thanks & Regards, Jeneesh k. v.
-
Hi, How to get the visitor's actual IP address. I have tried all the possible solution like HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"], UserHostAddress, Remote_ADDR etc etc. But all are returning the same IP that is I think proxy ip. If we are behind the firewall/proxy then is there any way to get the local IP of the system like 100.100.100.27. Please confirm. Pankaj
Get the visitor's actual IP address? Do you mean the visitor is using proxy? Try this function: Private Function getIP() Dim strIPAddr If Request.ServerVariables("HTTP_X_FORWARDED_FOR") = "" OR InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), "unknown") > 0 Then strIPAddr = Request.ServerVariables("REMOTE_ADDR") ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",") > 0 Then strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ",")-1) ElseIf InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";") > 0 Then strIPAddr = Mid(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), 1, InStr(Request.ServerVariables("HTTP_X_FORWARDED_FOR"), ";")-1) Else strIPAddr = Request.ServerVariables("HTTP_X_FORWARDED_FOR") End If getIP = Trim(Mid(strIPAddr, 1, 30)) End Function You can also get the visitor's IP by Request.UserHostAddress.