<%a=request.ServerVariables("SERVER_SOFTWARE")%>
select a
case "Microsoft-IIS/6.0"
response.write"Microsoft-IIS/6.0(Win2003)"
case "Microsoft-IIS/7.0"
response.write"Microsoft-IIS/7.0(Win2008)"
case "Microsoft-IIS/7.5"
response.write"Microsoft-IIS/7.5(Win2008 R2)"
服务器操作系统:<%=Request.ServerVariables("OS")%>服务器的名称和版本:<%=Request.ServerVariables("SERVER_SOFTWARE")%>
是这个
复制代码 代码示例:private void ButtonIP_Click(object sender, System.EventArgs e){ System.Net.IPAddress[] addressList = Dns.GetHostByName(Dns.GetHostName()).AddressListif ( addressList.Length>1){ TextLIP.Text = addressList[0].ToString()TextSIP.Text = addressList[1].ToString()}else{TextLIP.Text = addressList[0].ToString()TextSIP.Text = "没有可用的连接"}}另一种获取服务器的IP地址与MAC地址的方法:复制代码 代码示例:using System.Managementstring stringMAC = ""string stringIP = ""ManagementClass MC = new ManagementClass "Win32_NetworkAdapterConfiguration")ManagementObjectCollection MOC= MC.GetInstances()foreach(ManagementObject MO in MOC){if ((bool)MO["IPEnabled"] == true){stringMAC += MO["MACAddress"].ToString()TextMAC.Text = stringMAC.ToString()string[] IPAddresses = (string[]) MO["IPAddress"]if(IPAddresses.Length >0)stringIP = IPAddresses[0]TextIP.Text = stringIP.ToString()}}获取客户端本机的IP地址的方法:复制代码 代码示例:using System.NetTextIP.Text=Page.Request.UserHostAddress获取客户端本机的MAC地址刚复杂一些,需要调用两个API,用ARP协议获取,但也只能获取到同网段机器的MAC,对于跨网段的得利用IP扫描或cmd中nBTstat命令获取MAC地址。欢迎分享,转载请注明来源:夏雨云
评论列表(0条)