0

I have tried to get the Mac Address of local/client's machine but I am getting Mac address same in any of the device or computer. I have using th below code.

string macAddresses=null;
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
{
   if (nic.OperationalStatus == OperationalStatus.Up)
   {
       macAddresses += nic.GetPhysicalAddress().ToString();
       break;
    }
 }

Also, I have tried this link but I don't know how to add the reference of ManagementClass

Thanks in advance.

3
  • 1
    You cannot get the Mac Address of a client machine, only of the machine the code runs in Commented Nov 7, 2016 at 12:44
  • To use ManagementClass just add a reference to System.Management Commented Nov 7, 2016 at 12:46
  • I want to identify the device. is there any way that I can use? Commented Nov 7, 2016 at 12:51

2 Answers 2

1

There's no way to uniquely identity a client machine. The best you can do is add a cookie to the client with some sort of unique identifier. This is what Google and other ad and marketing companies do to try to track a user. However, any cookie set in a browser will not be available to an Android app to consume, so you'll still have no way to link the two. The only foolproof approach to uniquely identifying a user across multiple platforms is with an account. By the user signing at your website, then signing in on your Android app, you'll know it was the same user. Otherwise, you're out of luck.

Sign up to request clarification or add additional context in comments.

5 Comments

Chris, can you please explain the this line? The best you can do is add a cookie to the client with some sort of unique identifier.
What part are you having issues with?
The best you can do is add a cookie to the client with some sort of unique identifier.
The first time I will call the API from Mobile Browser and second time from the Mobile Application.
Which means that won't work for your scenario. What Google Analytics does, for instance, is set a cookie on the client (the web browser) with a unique identifier. That cookie, then, is available to the GA script on any other website using GA the user goes to. In that way Google can track where the user has been. However, the cookie is specific to the web browser session, and importantly would not be available to an Android app. The only way you can track the same user through both your site and Android app is via login.
0

You cannot get MAC address of client machine unless the client and server are both on the same LAN.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.