---
title: "How to get client IP address"  
description: "How to get client IP address"  
author: "Kenny Tangnde"  
published: 2011-09-29  
updated: 2011-10-01  
canonical: https://www.mindstick.com/forum/314/how-to-get-client-ip-address  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# How to get client IP address

Hi all,

How to get [client](https://www.mindstick.com/articles/23198/3-steps-to-ensure-that-your-client-portal-is-impeccable) [IP address](https://www.mindstick.com/articles/188405/difference-between-mac-address-and-ip-address),And will IP address [stored](https://www.mindstick.com/forum/157561/what-is-the-stored-procedure-create-a-procedure-to-find-the-record-by-stu_id-from-the-student-table) in the [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax)

thanks in advance.

## Replies

### Reply by Kenny Tangnde

**Hi Awadhendra Tiwari,** **My problem has been solved, thank you for your help.**

### Reply by Anonymous User

Hi...\
You can use following line of code to get machine name.\
\
Console.WriteLine(Environment.MachineName);\
\
Thanks.

### Reply by Kenny Tangnde

Hi Awadhendra Tiwari,

How get the local computer name.

Thanks.

### Reply by Kenny Tangnde

Hi Awadhendra Tiwari,

thanks for your helping.

```
using System.Net;namespace GetClientIPAddress{    class Program    {        static void Main(string[] args)        {            //GetHostByName(this parameter  is what).        IPAddress[] addresses = Dns.GetHostByName("").AddressList; //If only want IP. How to do that?       Console.Write("Your IP Address is:");            foreach (IPAddress address in addresses)            {                Console.WriteLine(address.ToString());            }            Console.ReadKey(true);        }    }}
```

### Reply by Anonymous User

Hi Aken,\
\
If you want to know client ip address in asp.net then you can use following code\
Request.UserHostAddress() ---> It will give you client address\
\
And if you want it in c# then you can write following code\
\
IPAddress[] addresses = Dns.GetHostByName( "MACHINE1" ).AddressList;\
\
foreach( IPAddress address in addresses )\
{\
Console.WriteLine( address.ToString() );\
}\
\
Thanks.

### Reply by Kenny Tangnde

for security,\
Consider the user's account unusual, such as remote login

### Reply by Anonymous User

Why you want to get client IP address?


---

Original Source: https://www.mindstick.com/forum/314/how-to-get-client-ip-address

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
