Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get IP Address of User using .net?

Tags:

c#

asp.net

In my web application i have registration form, when user register i want to get his ip address of his system, how can i get using asp.net. help me please.

like image 816
Surya sasidhar Avatar asked Oct 26 '09 03:10

Surya sasidhar


People also ask

How do I find the IP address of a networked user?

How do I identify an unknown device on my network? To see all of the devices connected to your network, type arp -a in a Command Prompt window. This will show you the allocated IP addresses and the MAC addresses of all connected devices.

Can you use netstat to find someone's IP?

Can I Track Someone's IP Address? Yes. As long as the device is on, connected to yours and doesn't have a proxy server or VPN obscuring it, you can track the IP address. If you want to find the IP of a device you're connected to, you can use the “netstat -an” command in the command prompt.

How do I find the IP address of a computer on my network using CMD?

From the desktop, navigate through; Start > Run> type "cmd.exe". A command prompt window will appear. At the prompt, type "ipconfig /all". All IP information for all network adapters in use by Windows will be displayed.

How do I find client IP address in net core?

Client IP address can be retrieved via HttpContext. Connection object. This properties exist in both Razor page model and ASP.NET MVC controller. Property RemoteIpAddress is the client IP address.


2 Answers

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"];
like image 143
Lance Harper Avatar answered Sep 23 '22 17:09

Lance Harper


HttpContext.Current.Request.UserHostAddress

like image 34
o.k.w Avatar answered Sep 24 '22 17:09

o.k.w