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. General Programming
  3. C#
  4. MAC Address

MAC Address

Scheduled Pinned Locked Moved C#
tutorial
13 Posts 7 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.
  • L Offline
    L Offline
    Lijjat
    wrote on last edited by
    #1

    How to get MAC Address and IP Address of recent visitor User

    T L D A D 8 Replies Last reply
    0
    • L Lijjat

      How to get MAC Address and IP Address of recent visitor User

      T Offline
      T Offline
      The Man from U N C L E
      wrote on last edited by
      #2

      In what context? Is this in a webservice, web application, windows service, active directory logon, vpn connection, remote desktop connection, citrix environment?

      If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) [My Articles]  [My Website]

      L 1 Reply Last reply
      0
      • L Lijjat

        How to get MAC Address and IP Address of recent visitor User

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Do you mean the recent visitor of ASP.NET web site? :)

        Life is a stage and we are all actors!

        L 1 Reply Last reply
        0
        • L Lost User

          Do you mean the recent visitor of ASP.NET web site? :)

          Life is a stage and we are all actors!

          L Offline
          L Offline
          Lijjat
          wrote on last edited by
          #4

          yes in web application

          L 1 Reply Last reply
          0
          • T The Man from U N C L E

            In what context? Is this in a webservice, web application, windows service, active directory logon, vpn connection, remote desktop connection, citrix environment?

            If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) [My Articles]  [My Website]

            L Offline
            L Offline
            Lijjat
            wrote on last edited by
            #5

            in the context of web application

            1 Reply Last reply
            0
            • L Lijjat

              How to get MAC Address and IP Address of recent visitor User

              D Offline
              D Offline
              dan sh
              wrote on last edited by
              #6

              To get IP of the visitor, you can use Javascript method: getHostAddress(). Getting Mac address will not be an easy task. I don't how or if you can get that, I am sure it is not easy.

              50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

              1 Reply Last reply
              0
              • L Lijjat

                How to get MAC Address and IP Address of recent visitor User

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                [Message Deleted]

                L 1 Reply Last reply
                0
                • L Lost User

                  [Message Deleted]

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Your answer is out of context. His question was how to find out the client's IP and MAC address from a web server when it connects to the server (not clear though).

                  1 Reply Last reply
                  0
                  • L Lijjat

                    yes in web application

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    I've taken a quick review of the standart HttpRequest headers, [^] but there isn't anything for MAC addresses so I suppose you can't get User MAC from server side code.You need client side code to do that.I've found this solution based on JavaScript and WMI but it works only with IE because it requires to run ActiveX control on the client side.

                    Life is a stage and we are all actors!

                    1 Reply Last reply
                    0
                    • L Lijjat

                      How to get MAC Address and IP Address of recent visitor User

                      A Offline
                      A Offline
                      Antony M Kancidrowski
                      wrote on last edited by
                      #10

                      HttpContext currentContext = HttpContext.Current;

                      string ip = currentContext.Request.UserHostAddress;

                      The MAC Address is unlikely to be the MAC of the machine browsing the web site. The MAC address of the IP packets changes as the packets pass through routers.

                      Ant. **I'm hard, yet soft.
                      I'm coloured, yet clear.
                      I'm fruity and sweet.
                      I'm jelly, what am I? Muse on it further, I shall return!

                      **- David Walliams (Little Britain)

                      1 Reply Last reply
                      0
                      • L Lijjat

                        How to get MAC Address and IP Address of recent visitor User

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #11

                        If you get it (and I'm not saying you can), then you would have to be very careful about what you do with it - you could easily break a lot of privacy laws

                        1 Reply Last reply
                        0
                        • L Lijjat

                          How to get MAC Address and IP Address of recent visitor User

                          D Offline
                          D Offline
                          Dave Kreskowiak
                          wrote on last edited by
                          #12

                          In a web application, there is no way to get the MAC address of the client. It wouldn't do you any good either since it only means something to the local subnet that the client machine is attached to. The MAC address that you might get is going to the from the last network interface to touch the packet before it got to your web server. This is usually the near-side of the last router or firewall that touched the packet before it got to your server. It will also be the same for every packet you get unless there is an alternate route for IP traffic to get to your server.

                          A guide to posting questions on CodeProject[^]
                          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                               2006, 2007, 2008
                          But no longer in 2009...

                          1 Reply Last reply
                          0
                          • L Lijjat

                            How to get MAC Address and IP Address of recent visitor User

                            P Offline
                            P Offline
                            PIEBALDconsult
                            wrote on last edited by
                            #13

                            There shouldn't be a need for it, but you could ask the visitor for it. :-D Don't attempt any sort of security or identity based on such addresses.

                            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