You can directly use the below function to your controller page.
Public string GetIp()
{
string ip = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(ip))
{
ip = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
return ip;
}
The above function will return client ip address.It is beeter to use than Request.UserHostAddress()
because sometimes it only capture the IP address of a user's proxy