日期:2014-05-17 浏览次数:20537 次
protected void Button1_Click(object sender, EventArgs e) { string ip=""; if (Request.ServerVariables["HTTP_VIA"] != null) { ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; } else { ip = Request.ServerVariables["REMOTE_ADDR"].ToString(); } TextBox1.Text = userIP; }
/// <summary> /// 获取局域网IP /// </summary> /// <returns></returns> public static string GetLocalhostIpAddress() { string localhostIp = ""; localhostIp = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString(); return localhostIp; }