ASP怎样获得本地的IP地址(我是通过代理上的)
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; }