Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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
Posted 21-Dec-11 2:51am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  
v2
Comments
robbiegis at 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 at 18-Jan-12 8:07am
   
...and you're tell ME this why?? Try replying to the original poster.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

For this you could use ManagementClass:
 

using (var mc = new ManagementClass("Win32_NetworkAdapterConfiguration"))
{
    foreach(ManagementObject mo in mc.GetInstances())
    {
        Console.WriteLine(mo["MacAddress"].ToString());
    }
}
  Permalink  
Comments
Sachin Suryawanshi at 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...
Laxmikant_Yadav at 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 at 21-Dec-11 8:05am
   
http://www.codeproject.com/Answers/187064/i-need-MAC-Address-of-client-machine-using-asp-net/?cmt=90859#answer1 check this out
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

// Hi
//this link may be useful;
 

[1] http://www.dotnetfunda.com/forums/thread2088-how-to-get-mac-address-of-client-machine.aspx
 

[2] http://stackoverflow.com/questions/2018982/how-to-get-mac-address-of-client-machine-in-c-sharp-and-vb-net
 

[3] use google
 

thanxxxxx
  Permalink  
Comments
Dave Kreskowiak at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

Hi Friends I have solve this problem.....
 
I will publish its solution in next 2 days.
 
Thanks
 
Sachin...
  Permalink  
Comments
Sandeep Mewara at 10-May-12 1:46am
   
Not an answer.
Raajkumar.b at 21-Dec-13 0:55am
   
what is the solution for this ,i am also having same requirement
can u help me ?
Lokendra Joshi at 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 at 18-Jun-12 4:42am
   
I have applied following...it 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>';
while(!e.atEnd())
{
e.moveNext();
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>';
document.getElementById("box").innerHTML=output;
}

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

  Print Answers RSS
0 OriginalGriff 359
1 Maciej Los 290
2 Sergey Alexandrovich Kryukov 230
3 Shweta N Mishra 185
4 PIEBALDconsult 149
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,760


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 10 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100