how to get mac address of client that browse web site by asp.net mvc c#

后端 未结 2 1948
忘了有多久
忘了有多久 2020-11-27 20:18

I\'m trying to get mac address from the client\'s machine that browse my web site, I\'ve been used this:

using System.Management;
class Sample_ManagementClas         


        
2条回答
  •  再見小時候
    2020-11-27 21:18

    it's unfortunately not possible to reliably get the mac address of the client machine due to firewalls, proxies and ISP generic addresses being given. However, you can make a stab at getting the ip address by using:

    var remoteIpAddress = Request.UserHostAddress;
    

    However, this may or may not actually represent the client machine and is more likely the ISP gateway or some other ip address. It's a well known problem and one that even google have found hard to crack using clientside javascript (the idea here being that you get the actual local ip address via a js library and pass that over to your server function).

    [edit] - might be worth taking a look at the following for inspiration/confirmation of the issue:

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

提交回复
热议问题