Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to get mac address of a client system in asp.net

How to get mac address of a client system in asp.net

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nettutorialquestion
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mithun narayanan
    wrote on last edited by
    #1

    Hi All. How to get mac address of a client system in asp.net?? I need to identify client system uniquely other than using IP address. If there is any other way for achieving the same please suggest... Thanks and Regards Mithun Narayanan.

    E A A 4 Replies Last reply
    0
    • M mithun narayanan

      Hi All. How to get mac address of a client system in asp.net?? I need to identify client system uniquely other than using IP address. If there is any other way for achieving the same please suggest... Thanks and Regards Mithun Narayanan.

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      And it involved this very issue. And a Senior MS Consultant (I hate to admit) showed me the path towards righteousness. Basically, your MAC address gets replaced with each frame along each router or some such non-sense. Meaning that outside your local network the MAC is meaningless. Much worse, some TCP/IP stacks do not even provide it through the API so you would need to really write some code to get it. http://tools.ietf.org/html/rfc1122[^] http://en.wikipedia.org/wiki/Ethernet[^]

      Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

      1 Reply Last reply
      0
      • M mithun narayanan

        Hi All. How to get mac address of a client system in asp.net?? I need to identify client system uniquely other than using IP address. If there is any other way for achieving the same please suggest... Thanks and Regards Mithun Narayanan.

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        In case of ASP.NET it is a client server architecture.. So you can only get things that are sent through request object. As every request is made by the browser (client) you can add the mac address to it and send it. So only option is your IP.... which is also the external one. :(

        Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


        My Latest Articles-->** Windows7 API Code Pack
        Simplify Code Using NDepend
        Basics of Bing Search API using .NET

        M 1 Reply Last reply
        0
        • M mithun narayanan

          Hi All. How to get mac address of a client system in asp.net?? I need to identify client system uniquely other than using IP address. If there is any other way for achieving the same please suggest... Thanks and Regards Mithun Narayanan.

          A Offline
          A Offline
          April Fans
          wrote on last edited by
          #4

          Hi,try to do this. using System.Management; string stringMAC = ""; string stringIP = ""; ManagementClass MC = new ManagementClass "Win32_NetworkAdapterConfiguration"); ManagementObjectCollection MOC= MC.GetInstances(); foreach(ManagementObject MO in MOC) { if ((bool)MO["IPEnabled"] == true) { stringMAC += MO["MACAddress"].ToString(); TextMAC.Text = stringMAC.ToString(); string[] IPAddresses = (string[]) MO["IPAddress"]; if(IPAddresses.Length > 0) stringIP = IPAddresses[0]; TextIP.Text = stringIP.ToString(); } }

          April Comm100 - Leading Live Chat Software Provider

          M 1 Reply Last reply
          0
          • M mithun narayanan

            Hi All. How to get mac address of a client system in asp.net?? I need to identify client system uniquely other than using IP address. If there is any other way for achieving the same please suggest... Thanks and Regards Mithun Narayanan.

            A Offline
            A Offline
            April Fans
            wrote on last edited by
            #5

            Hi, you can refer to the following code: [DllImport("Iphlpapi.dll")] private static extern int SendARP(Int32 dest,Int32 host,ref Int64 mac,ref Int32 length); [DllImport("Ws2_32.dll")] private static extern Int32 inet_addr(string ip); private void Page_Load(object sender, System.EventArgs e) { // initial page try { string userip=Request.UserHostAddress; string strClientIP = Request.UserHostAddress.ToString().Trim(); Int32 ldest = inet_addr(strClientIP); //client ip Int32 lhost = inet_addr(""); //server ip Int64 macinfo = new Int64(); Int32 len = 6; int res = SendARP(ldest,0, ref macinfo, ref len); string mac_src=macinfo.ToString("X"); if(mac_src == "0") { if(userip=="127.0.0.1") Response.Write ("Localhost!"); else Response.Write ("welcome IP = " + userip + "<br>"); return; } while(mac_src.Length<12) { mac_src = mac_src.Insert(0,"0"); } string mac_dest=""; for(int i=0;i<11;i++) { if (0 == (i % 2)) { if ( i == 10 ) { mac_dest = mac_dest.Insert(0,mac_src.Substring(i,2)); } else { mac_dest ="-" + mac_dest.Insert(0,mac_src.Substring(i,2)); } } } Response.Write ("welcome IP = "+userip+ "<br>" + ",MAC = "+mac_dest + "<br>"); } catch(Exception err) { Response.Write(err.Message); } }

            April Comm100 - Leading Live Chat Software Provider

            M 1 Reply Last reply
            0
            • A Abhishek Sur

              In case of ASP.NET it is a client server architecture.. So you can only get things that are sent through request object. As every request is made by the browser (client) you can add the mac address to it and send it. So only option is your IP.... which is also the external one. :(

              Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


              My Latest Articles-->** Windows7 API Code Pack
              Simplify Code Using NDepend
              Basics of Bing Search API using .NET

              M Offline
              M Offline
              mithun narayanan
              wrote on last edited by
              #6

              Sorry i cant use IP... if am using it i cant uniquly identify systems under a particular network... is ther any other way... i can it thru javascript but i ve to enable ActiveX which i dont want... :( is ther any other way.??

              1 Reply Last reply
              0
              • A April Fans

                Hi,try to do this. using System.Management; string stringMAC = ""; string stringIP = ""; ManagementClass MC = new ManagementClass "Win32_NetworkAdapterConfiguration"); ManagementObjectCollection MOC= MC.GetInstances(); foreach(ManagementObject MO in MOC) { if ((bool)MO["IPEnabled"] == true) { stringMAC += MO["MACAddress"].ToString(); TextMAC.Text = stringMAC.ToString(); string[] IPAddresses = (string[]) MO["IPAddress"]; if(IPAddresses.Length > 0) stringIP = IPAddresses[0]; TextIP.Text = stringIP.ToString(); } }

                April Comm100 - Leading Live Chat Software Provider

                M Offline
                M Offline
                mithun narayanan
                wrote on last edited by
                #7

                Thank u for the response.. i ll try this nd revert ..

                A 1 Reply Last reply
                0
                • A April Fans

                  Hi, you can refer to the following code: [DllImport("Iphlpapi.dll")] private static extern int SendARP(Int32 dest,Int32 host,ref Int64 mac,ref Int32 length); [DllImport("Ws2_32.dll")] private static extern Int32 inet_addr(string ip); private void Page_Load(object sender, System.EventArgs e) { // initial page try { string userip=Request.UserHostAddress; string strClientIP = Request.UserHostAddress.ToString().Trim(); Int32 ldest = inet_addr(strClientIP); //client ip Int32 lhost = inet_addr(""); //server ip Int64 macinfo = new Int64(); Int32 len = 6; int res = SendARP(ldest,0, ref macinfo, ref len); string mac_src=macinfo.ToString("X"); if(mac_src == "0") { if(userip=="127.0.0.1") Response.Write ("Localhost!"); else Response.Write ("welcome IP = " + userip + "<br>"); return; } while(mac_src.Length<12) { mac_src = mac_src.Insert(0,"0"); } string mac_dest=""; for(int i=0;i<11;i++) { if (0 == (i % 2)) { if ( i == 10 ) { mac_dest = mac_dest.Insert(0,mac_src.Substring(i,2)); } else { mac_dest ="-" + mac_dest.Insert(0,mac_src.Substring(i,2)); } } } Response.Write ("welcome IP = "+userip+ "<br>" + ",MAC = "+mac_dest + "<br>"); } catch(Exception err) { Response.Write(err.Message); } }

                  April Comm100 - Leading Live Chat Software Provider

                  M Offline
                  M Offline
                  mithun narayanan
                  wrote on last edited by
                  #8

                  Thank u for the response..

                  1 Reply Last reply
                  0
                  • M mithun narayanan

                    Thank u for the response.. i ll try this nd revert ..

                    A Offline
                    A Offline
                    Abhishek Sur
                    wrote on last edited by
                    #9

                    ha ha ... this will give you the Mac address of the Server. .. :laugh:

                    Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                    My Latest Articles-->** Windows7 API Code Pack
                    Simplify Code Using NDepend
                    Basics of Bing Search API using .NET

                    M 1 Reply Last reply
                    0
                    • A Abhishek Sur

                      ha ha ... this will give you the Mac address of the Server. .. :laugh:

                      Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                      My Latest Articles-->** Windows7 API Code Pack
                      Simplify Code Using NDepend
                      Basics of Bing Search API using .NET

                      M Offline
                      M Offline
                      mithun narayanan
                      wrote on last edited by
                      #10

                      i knw tat... i ve tried it long back ago...

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups