Can I get a MAC address that are connected to my site.
this code get mac address host and return error permission.
String macadress = string.Empty;
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
{
OperationalStatus ot = nic.OperationalStatus;
if (nic.OperationalStatus == OperationalStatus.Up)
{
macadress = nic.GetPhysicalAddress().ToString();
break;
}
}
return macadress;
now how can get mac address users???
2.
how can get ip users???
Unfortunately you can’t get the user’s MAC address in the way that you want. It’s my understanding that MAC addresses are stripped from packets when they leave your local network.
You can try to get the user’s address from
Request.UserHostAddress. However if you are behind a load balancer or content distribution network then you might want to try looking inRequest.Headers["X-Forwarded-For"]first – this is where the users original IP address will often be written when the request is forwarded on by something.The approach I’ll usually take is to try something along the lines of:
The last project I worked on, we actually logged both, in case the forwarded for header had been faked.