i'm using ASP.NET webforms, and would like to get the ip and MAC address of a client visiting my site. Is it possible ?
Asked
Active
Viewed 2,485 times
-2
-
Why do you need the MAC address? – Oliver Charlesworth May 04 '14 at 13:32
-
To store in the DB so i can take care that no double vote will be registered. – Adam Bickels May 04 '14 at 13:33
-
@AdamB: Storing IP addresses will not help you do that. Individuals can have many IPs, and entire countries can share an IP. – SLaks May 04 '14 at 13:36
2 Answers
0
You can get the IP address from Request.UserHostAddress
.
You cannot get the MAC address.

SLaks
- 868,454
- 176
- 1,908
- 1,964
0
You can get IP address using Request.UserHostAddress or Request.ServerVariables["REMOTE_ADDR"]. If client is behind the proxy server then you can try to obtain his IP using ServerVariables["HTTP_X_FORWARDED_FOR"]. Read here for more details.
You can't get the MAC addresses unless your clients are on the same physical subnet as the server. To get MAC address within intranet
//get all nics
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
//display the physical address of the first nic in the array,
//which should correspond to our mac address
Label1.Text = nics[0].GetPhysicalAddress().ToString();
or read more here.

Community
- 1
- 1

user2316116
- 6,726
- 1
- 21
- 35