Hi,
Try with the below code
HttpRequest request = HttpContext.Current.Request;
string ipAddress = request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (ipAddress == null || ipAddress.ToLower() == "unknown")
ipAddress = currentRequest.ServerVariables["REMOTE_ADDR"];
return ipAddress;
This may help you.