1

Is it possible that store IP and/or MAC address of client system in Cookie in ASP.NET

Zong
  • 6,160
  • 5
  • 32
  • 46
Nimesh
  • 3,342
  • 1
  • 28
  • 35
  • IP yes, MAC no(you just can't get client's MAC address) – Uriil Jun 06 '14 at 17:37
  • If you're going to post a question, you might as well make it worth your while and ask **how** rather than simply asking if it's possible. – mason Jun 06 '14 at 17:38
  • Look at this [link](http://www.codeproject.com/Questions/399318/How-to-Get-User-IP-address-using-csharp) – Rex Jun 06 '14 at 17:38
  • 1
    MAC too. He does not ask where to get it but whether they an be stored. As a cookie stores a string, and the MAC Address can be written as a string, it can be stored. – TomTom Jun 06 '14 at 17:39
  • I'll add that if the OP IS looking to get a MAC from IP it can be done on a local network with arp but this is probably not going to work for many people. – Mike Cheel Jun 06 '14 at 17:41
  • @TomTom I would mention that getting the MAC address, even in the browser, is not only complicated but purposefully restricted. http://stackoverflow.com/questions/3385/mac-addresses-in-javascript – Mike Perrenoud Jun 06 '14 at 17:41
  • 1
    @MichaelPerrenoud Not disputing it. But the question is not about how to get them. – TomTom Jun 06 '14 at 17:44

2 Answers2

2

It is possible to store anything relatively small (<100K) in cookies, obtaining information is whole other story.

After you obtained IP / MAC (hard to do on web page, and "really useful IP" is pretty much non-existent thing) you may need to encode value to put in cookies.

Obtaining MAC - not possible via normal JavaScript. Trusted site/trusted control may be able to obtain one MAC addresses in JavaScript.

Obtaining IP - externally visible IP is available on your server as header, you can also find existing service that will give you such IP. Note that it most cases it is different from IP of local machine visible locally.

Community
  • 1
  • 1
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
1

The IP address of the user is stored in Request.UserHostAddress.

Slider345
  • 4,558
  • 7
  • 39
  • 47