//方式一
string clientIP;
if (Context.Request.ServerVariables["HTTP_VIA"] != null)
{
clientIP = Context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else
{
clientIP = Context.Request.ServerVariables["REMOTE_ADDR"].ToString();
}
this.Label1.Text = clientIP;
//方式二
using System.Net;
IPHostEntry ipHostEntry = Dns.GetHostByName(Dns.GetHostName());
//获得本机IP地址
IPAddress addr = new IPAddress(ipHostEntry.AddressList[0].Address);
this.Label1.Text = addr.ToString();
//方式三
this.Label1.Text=Request.Url.Host;