Can i get from a client who visits my site some unique key like MAC Address ? i'm trying to get this id to store in the db so client can't access it anymore if it already visits the page.
-
possible duplicate of [How do I uniquely identify computers visiting my web site?](http://stackoverflow.com/questions/216542/how-do-i-uniquely-identify-computers-visiting-my-web-site) – Simon Mourier May 04 '14 at 17:06
3 Answers
To get the user's IP address, you can use what others have suggested. However, you cannot obtain a user's MAC address unless they are directly connected to your router.
If you want to uniquely identify your user, you should try to identify them by a combination of IP, OS and some other specific data. However, this will still not be entirely reliable.
If you allow registration on your website, then you could identify users by their e-mail addresses.
There is a question on StackOverflow that seems to be about the same thing: How do I uniquely identify computers visiting my web site?. An answer there suggests the usage of cookies. You might want to check out the following article: Beginner's Guide to ASP.NET Cookies.
You can't get the MAC Address of your client
to get the IP address use
string ipaddress; ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (ipaddress == "" || ipaddress == null) ipaddress = Request.ServerVariables["REMOTE_ADDR"];
http://www.aspsnippets.com/Articles/How-to-get-IP-Address-of-Visitors-Machine-in-ASP.Net.aspx

- 14,987
- 4
- 32
- 49
-
-
NOTE: the remote address may not be very useful, particularly if they are coming from an environment using NAT. You can have hundreds of users that appear to be using the same network address, due to gateways and and IPv4 net address translation (NAT). – Berin Loritsch Jun 01 '18 at 12:54
Gives Random Hex Number Each Time New One
string newID= Guid.NewGuid().ToString();

- 10,077
- 1
- 29
- 51