Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to get connected client mac ID (Physical address)

How can i do this by using server side language like C#,VB.net with asp.net
Posted
Comments
Abhijit Barua 21-Nov-11 7:09am    
u can c this link
http://www.daniweb.com/software-development/csharp/threads/232662
http://www.dotnetboss.com/2010/04/27/how-to-get-mac-address-using-c/

You can get client's IP address using following code,

C#
Request.UserHostAddress
 
Share this answer
 
The MAC address isn't in the client request headers, so the only thing you've got in the clients IP address to use. You can't get the MAC address of the client unless the server is on the same network segment as the client.

What'll happen is you'll get the clients IP address, try to resolve it to a MAC using ARP, but then you'll find that the MAC you get back is the same for just about all of your clients (depending on network layout) and it's the MAC for the routers near-side interface. This is the first hop from the server back to the client.
 
Share this answer
 
use this c# code


C#
MACAddress = MACAddress.Replace(":", "");
Response.Write(MACAddress);

string macAddresses = "";
foreach (System.Net.NetworkInformation.NetworkInterface nic in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces())
{
    if (nic.OperationalStatus == System.Net.NetworkInformation.OperationalStatus.Up)
    {
        macAddresses += nic.GetPhysicalAddress().ToString();
        break;
    }
}
Response.Write(macAddresses);
 
Share this answer
 
v2
Comments
Dave Kreskowiak 12-Dec-11 8:05am    
So, on every request, you're going to get the MAC addresses of the IIS server?? That's what your code is saying...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900