Here is the simple code to do this task
protected void Button1_Click(object sender, EventArgs e)
string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
SqlCommand cmd = new SqlCommand(“insert into tblIpAddress(IPAddress)values(@IPAddress)”, con);
Here its work localhost but it host in server the ip address show blank
Please check it properly.I have used this code in one live project.It was working fine.
This wil give server ip address and not visitor /client ip address
Thanks for updating me. I will check it.
I really like reading an article that can make people think.
Also, thank you for permitting me to comment!