Here is my Generic Utility for IP:
public static string GetUserIPAddress()
{
Page page = HttpContext.Current.Handler as Page;
string ip = page.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (!string.IsNullOrEmpty(ip))
{
string[] ipRange = ip.Split(',');
ip = ipRange[0];
}
else
{
ip = page.Request.ServerVariables["REMOTE_ADDR"];
}
return ip.Trim();
}