1

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.

Ajay
  • 2,022
  • 19
  • 33
Adam Bickels
  • 461
  • 12
  • 30
  • 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 Answers3

2

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.

Community
  • 1
  • 1
Igor Ševo
  • 5,459
  • 3
  • 35
  • 80
1

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

Sajad Karuthedath
  • 14,987
  • 4
  • 32
  • 49
  • @SJD: Exactly mate..!! – Sajad Karuthedath May 04 '14 at 16:04
  • 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
0

Gives Random Hex Number Each Time New One

string newID= Guid.NewGuid().ToString();
Dgan
  • 10,077
  • 1
  • 29
  • 51