Click here to Skip to main content
15,935,248 members
Please Sign up or sign in to vote.
3.00/5 (4 votes)
Hello Friends,

I want the Client Machines Mac Address in Asp.Net.

Is it Possible or not ?

Code should work in all browser..

Thanks in Advance

What none of these schmucks are telling you (because they have no idea what they're doing) is what you want isn't possible in most cases.

The solutions provided so far will only work on Windows machines, IF and only IF your server ASP.NET account has permissions to the client machine. Chances are really good that your ASP.NET server account does NOT have any permissions at all to your client machines. That means you can't get the info you want using WMI.

So that leaves resolving the physical address using ARP. The problem with that is ARP is only good on the local network. That means ARP will return physical address on the network local to the caller, your server. If you try to resolve an IP address to a physical address for a remote machine in another subnet or acrossed the internet somewhere, you'll get back the physical address of the near-side interface of the first router your network path encounters going from the server to the client, not of the client machine.

Why? You'll have to read up on how TCP/IP routing works.

Oh, and another thing. MAC addresses are NOT unique. Multiple computers CAN have the same MAC address for an interface. MAC addresses cannot be used to identify individual computers or as the sole key material in an encryption or hashing algorithm.
Share this answer
robbiegis 18-Jan-12 1:09am    
Getting IP address or Hostname of the client machine is possible but for mac address it is not. If we use javascript then we have to lower the security settings of IE which is again a issue and then this javascript works only in IE. so it is better to install something on the client which sends the mac and ip combination.
Dave Kreskowiak 18-Jan-12 8:07am    
...and you're tell ME this why?? Try replying to the original poster.
I think you'd need some type of filter at the IIS level to get the MAC address from the IP packets and inject it into the request somehow. I'm not sure of the details, but I know the only place you are going to get the MAC address is at the network (socket) level. By the time you are in ASP.NET, you are way too far abstracted from the network level. IIS filters may even be too far away.

EDIT: Getting the MAC address via the network packet is likely only going to be valid on the same network segment -- routers in between will alter the MAC address. If you want the MAC address, your client needs to query it and send it with your request. It's more a of client-side technical hurdle at that point.
Share this answer
Hi Friends I have solve this problem.....

I will publish its solution in next 2 days.


Share this answer
Sandeep Mewara 10-May-12 1:46am    
Not an answer.
Raajkumar.b 21-Dec-13 0:55am    
what is the solution for this ,i am also having same requirement
can u help me ?
Lokendra Joshi 18-Jun-12 4:40am    
Hi Sachin,

Can you please share your ideas about with me to get MAC Address of client Machine. I need your help as you have solution for the same.
Lokendra Joshi 18-Jun-12 4:42am    
I have applied was running properly but it have browser dependency.....
function showMacAddress()
var obj = new ActiveXObject("WbemScripting.SWbemLocator");
var s = obj.ConnectServer(".");
var properties = s.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
var e = new Enumerator (properties);
var output;
output='<table border="0" cellPadding="5px" cellSpacing="1px" bgColor="#CCCCCC">';
output=output + '<tr bgColor="#EAEAEA"><td>Caption</td><td>MACAddress</td></tr>';
var p = e.item ();
if(!p) continue;
output=output + '<tr bgColor="#FFFFFF">';
output=output + '<td>' + p.Caption; + '</td>';
output=output + '<td>' + p.MACAddress + '</td>';
output=output + '</tr>';
output=output + '</table>';
For this you could use ManagementClass:

using (var mc = new ManagementClass("Win32_NetworkAdapterConfiguration"))
    foreach(ManagementObject mo in mc.GetInstances())
Share this answer
Sachin Suryawanshi 21-Dec-11 8:01am    
Thanks but this code shows the MAC Address of server it self.

I want to retrieve the MAC Address of Client Machine...
LaxmikantYadav 21-Dec-11 8:11am    
Above code is of WMI. you can run it on remote machine also. Google for remote WMI query.
Syed Salman Raza Zaidi 21-Dec-11 8:05am check this out
// Hi
//this link may be useful;



[3] use google

Share this answer
Dave Kreskowiak 16-Feb-12 12:09pm    
You didn't actually read these links, did you? If you did and if you understood how networking works, you'd know that the solutions provided do not work in an ASP.NET app and getting the MAC address of a client is not possible.

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