Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello everybody,

I want to retrieve my client Mac and IP address by my web page.
Anybody could help me or at least guide me?
I have tried some samples in google ,but all of them return my host IP .

In advanced,thanks.
Posted

Have you searched the CP Q/A and/or Googled it "properly" before? Google itself gives about 4.43 million results.
If not then Let Me (properly) Google That For You![^]

And this CP Question[^] is the top result.
 
Share this answer
 
For the IP check here: http://www.etechpulse.com/2013/04/how-to-get-ip-address-aspnet.html[^].
But you can resolve it to MAC only if the server and the client are on the same VLAN - if there is no router between them. In this case you can use ARP protocol. Check here: http://www.news2news.com/vfp/?example=585&ver=vcs[^].
You could get MAC address from client side, but only in a platform and browser dependent way, thus not reliable in any form: http://www.nullskull.com/q/10054371/how-to-get-client-mac-address.aspx[^]. I don't know what your intentions with the MAC were, but I suggest you forget them. It is not good for identification. It is not even guaranteed to be unique - and can be changed in most NICs.
 
Share this answer
 
I don't think getting Mac will be that easy in many scenarios(I haven't tried it yet),but to retrieve client's IP address,you can do something like below.
C#
string ip = Server.HtmlEncode(Request.UserHostAddress);

This will give you ip as a string.

Note:

You will get 127.0.0.1 every time if you run it from localhost.

Regards..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900