public static Class Iphelper
{
<summary>
Get IP
</summary>
<returns></returns>
public static string GetIP ()
{
String[] ip_ary;
String StrIP, Strip_list;
Strip_list = system.web.httpcontext.current.request.servervariables["Http_x_forwarded_for"];
if (strip_list! = NULL && strip_list! = "")
{
Strip_list = Strip_list. Replace ("'", "");
if (strip_list. IndexOf (",") >= 0)
{
Ip_ary = Strip_list. Split (', ');
StrIP = ip_ary[0];
}
Else
{
StrIP = strip_list;
}
}
Else
{
StrIP = "";
}
if (StrIP = = "")
{
StrIP = system.web.httpcontext.current.request.servervariables["REMOTE_ADDR"];
StrIP = Strip.replace ("'", "" ");
}
return StrIP;
}
private static double Iptonum (string IP)
{
int S1 = 1;
int s2 = S1;
int s3 = s2;
int s4 = S3;
string[] IpNs = IP. Trim (). Split ('. ');
Try
{
Double IpN = convert.todouble (Ipns[0]) * S4 + convert.todouble (ipns[1]) * s3 + ipns[2]. ToInt () * s2 + ipns[3]. ToInt () * S1;
return IpN;
}
catch (Exception)
{
return 0;
}
}
}
Common Tool Class 4-ip class