How to Get the IP Address of any Client System by c# ?

“How to get client ip address in using c#,Find IP Client address using C# Program,Get Client IP Address and Location in ASP.Net using C#”

Hello friends Today, through this tutorial, we will learn how to get the ip address of any client from the c#.

Friends, we are working on a big project any time, and when using a user login or register we want anyone who registers or logins it, what IP address is doing so, so that we can get the information.

So today we will learn by c# language. There are also some inbuilt code or function in c#. Which are already made up. Which we just have to use correctly.

Apart from c#, you can easily get the IP address of the client’s system by javascript or jquery. But we are talking about how to get the ip address of any client system by c#.

Let’s move on. We’ll explain you step by step. You can see below.


string IPAddress = GetIPAddress();
public string GetIPAddress()
IPHostEntry Host = default(IPHostEntry);
string Hostname = null;
Hostname = System.Environment.MachineName;
Host = Dns.GetHostEntry(Hostname);
foreach (IPAddress IP in Host.AddressList) {
if (IP.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) {
IPAddress = Convert.ToString(IP);
return IPAddress;

Dim Host As IPHostEntry
Dim Hostname As String
Hostname = My.Computer.Name
Host = Dns.GetHostEntry(Hostname)
For Each IP As IPAddress In Host.AddressList
If IP.AddressFamily = System.Net.Sockets.AddressFamily.InterNetwork Then
IPAddress = Convert.ToString(IP)
End If
Return IPAddress