1.获取客户端IP地址
public string getip()
{
return Request.UserHostAddress;
}
2.获取客户端主机名称
public string gethostname()
{
return Request.UserHostName;
}
3.获取客户端网卡物理地址
public string getmac(string ip)
{
string dirResults="";
ProcessStartInfo psi = new ProcessStartInfo();
Process proc = new Process();
psi.FileName = "nbtstat";
psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = true;
psi.Arguments = "-A " + ip;
psi.UseShellExecute = false;
proc = Process.Start(psi);
dirResults = proc.StandardOutput.ReadToEnd();
string rtn = dirResults.Substring(dirResults.IndexOf("=")+1);
return rtn;
}
4.引申
通过ProcessStartInfo(),调用在aspnet用户权限范置内的DOS命令,可以获得相应处理结果
<script type="text/javascript"> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>