本文介绍了跟踪mac地址和ip地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hai朋友我已经在公共服务器上部署了一个项目现在我想跟踪那些正在使用该项目的人的mac地址和ip地址(该项目是一个网站)所以当他们打开那个网站我需要跟踪mac地址和该特定电脑的IP地址。请帮助我。谢谢。
Hai friends i have deployed a project in public server now i want to trace mac address and ip address of those who are using that project(that project is a website) so when they open that website i need to trace mac address and ip address of that particular pc. Kindly help me. Thank you.
推荐答案
<pre lang="cs">public object ClientIpAddress(HttpRequest myRequest)
{
string myIP = "";
if ((string.IsNullOrEmpty(myIP)))
myIP = myRequest.ServerVariables("HTTP_CLIENT_IP");
if ((string.IsNullOrEmpty(myIP)))
myIP = myRequest.ServerVariables("HTTP_X_FORWARDED_FOR");
if ((string.IsNullOrEmpty(myIP)))
myIP = myRequest.ServerVariables("HTTP_X_FORWARDED");
if ((string.IsNullOrEmpty(myIP)))
myIP = myRequest.ServerVariables("HTTP_X_CLUSTER_CLIENT_IP");
if ((string.IsNullOrEmpty(myIP)))
myIP = myRequest.ServerVariables("HTTP_FORWARDED_FOR");
if ((string.IsNullOrEmpty(myIP)))
myIP = myRequest.ServerVariables("HTTP_FORWARDED");
if ((string.IsNullOrEmpty(myIP)))
myIP = myRequest.ServerVariables("REMOTE_ADDR");
return myIP;
}
public string Host2Ip(string HostName)
{
string functionReturnValue = null;
try {
System.Net.IPHostEntry myIPs = null;
myIPs = System.Net.Dns.GetHostEntry(HostName);
functionReturnValue = myIPs.AddressList[0].ToString();
} catch (Exception ex) {
//Handle the error
}
return functionReturnValue;
}</pre>
这篇关于跟踪mac地址和ip地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!