How to get user IP address using .net?

In my web application, I have a registration form, when a user logs in, I want to get his system ip address, how can I use asp.net. help me please.

+5
source share
3 answers
HttpContext.Current.Request.UserHostAddress; 

or

HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

To get the IP address of the machine, not the proxy, use the following code

HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
+9
source

HttpContext.Current.Request.UserHostAddress

+3
source

Try:

Request.ServerVariables["REMOTE_ADDR"].ToString() 
+2
source

All Articles