Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 03, 2011 03:57 AM by prakash.radhwani
Jan 08, 2008 05:42 AM|LINK
Getting user's country name using ip Address
Jan 24, 2008 05:16 PM|LINK
Even I have simillar kind of problem.
We have intranet application and I need to cature the IPAddress of the client.
I am trying to capture the remote address.
I tried in different ways as below.. but the result of all is 127.0.0.1
I guess firewall/NAT Box hiding internal IP addresses.
is there any way to get actual IP.
Thanks in advance.
Feb 06, 2008 12:54 PM|LINK
Hi vitta, I got the same problem and I found the solution by doing dis:
string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
I got this solution from C# corner. website
client ip address
Feb 12, 2008 06:22 AM|LINK
This example demonstrates how to find out the visitor's browser type, IP address, and more:
<b>You are browsing this site with:</b>
<b>Your IP address is:</b>
<b>The DNS lookup of the IP address is:</b>
<b>The method used to call the page:</b>
<b>The server's domain name:</b>
<b>The server's port:</b>
<b>The server's software:</b>
Mar 31, 2008 08:22 PM|LINK
Thanks Zestq..its working fine.. This is what I exactly want..
I really wonder why others given examples with server variables.
I already said, I tried with server variables and couldnt succeed in INTRNET environment where proxy is hiding the original IP.
API's under DNS class are solution for my problem.
Thanks again Zestq
Apr 13, 2008 07:14 PM|LINK
To get the IP address of the machine and not the proxy use the following code
Thanks this works for me.
So I can log every user login and their IP.
I use it like this in c#. Using
This Sql Connection class as MySql.
MySqlConnection MySql =
string ip = HttpContext.Current.Request.UserHostAddress;
MySql.Command = MySql.Connection.CreateCommand();
MySql.Command.CommandType = CommandType.Text;
MySql.Command.CommandText = "INSERT INTO dbo.[log.login] (userID, IP, DateTimeStamp, TargetPage) VALUES (" + myUserID +
", '" + ip +
"', '" +
"', '" + Server.UrlDecode(Request.QueryString["p"]) +
May 04, 2008 01:13 PM|LINK
Thanks ZESTQ, It really works for me......
May 08, 2008 02:44 AM|LINK
for the solution that you provided on February, Do u know how to solve it by using vb.NET?
Hope to hear anyone of you, thank you
Jun 12, 2008 11:14 AM|LINK
Hi guyz, The solution I have provided gives the IP Address but If you look into it, It gives you the server IP not the client;s IP Address, while I guess we all need the client's IP Address or the visitor's IP.
To get the Client's IP Address, try this:
NOTE: when you run this it will give you "127.0.0.1", this is because, you are using from the HOST Machine i.e. the application is on ur machine and it is giving you, ur IP address but
when any visitor or client hits ur page it will give you the exact IP Address of the Client.
I have checked this on my LAN and its working fine,,,,,try this and if it fails do inform me or any 1 got any better solution please let me know.
client ip address
visitors ip address
client machine ip address
Jun 12, 2008 11:21 AM|LINK
Hi Hideyoshi here is the VB version of both of my codes:
Dim strHostName As String = System.Net.Dns.GetHostName()
Dim clientIPAddress As String = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString()
Dim clientIPAddress As String = Me.Page.Request.ServerVariables("REMOTE_ADDR"
Following site address is the converter of VB.NET code to C# and vice versa (I have also used this site 2 convert my code).
VB.NET code to C# Converter