HttpContext.Current.Request.UserHostAddress
This does not attempt to take proxies into account. You can use for this Request.ServerVariables["HTTP_X_FORWARDED_FOR"]. However, make sure that you do not blindly trust this, as it can be faked. Itβs better to keep a whitelist of the IP addresses you trust.
source
share