Click here to Skip to main content
15,906,329 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hai friends i have deployed a project in public server now i want to trace mac address and ip address of those who are using that project(that project is a website) so when they open that website i need to trace mac address and ip address of that particular pc. Kindly help me. Thank you.
Posted
Comments
Thanks7872 7-Nov-13 1:09am    
So we are suppose to do your home work right? Don't you have access to google? You can easily find at least 1000 threads regarding the same.

Learn how TCP/IP and Routing works before you start throwing around "track MAC address". You will NOT get the MAC of the client unless it's inside the same network segment as your server. You'll get the MAC of the near-side interface of the router nearest the server.

There is no way to get the MAC address of a web client on the other side of a router.
 
Share this answer
 
Comments
kalyan10qwerty 7-Nov-13 0:48am    
so can i trace atleast ip address of those who are using my project
Dave Kreskowiak 7-Nov-13 7:27am    
Ignore the other answers. Your ASP.NET site gets the IP address of the client in the headers of every request your site gets. You don't need WMI at all and they have no idea how the code they posted works or why it's wrong.

You'd use Request.UserHostAddress to get the IP address of the client.

BUT!! Say this user is behind a NAT/Router, like behind a cable modem attached to a home router. Each client behind the users router will have the same IP address. You'll be getting the IP of the users router, NOT the internal IP address on the clients internal network. You can do nothing about this.

If you're trying to use IP addresses to uniquely identify a machine, even in the above circumstances, you cannot do it using MAC and IP addresses.
Get Client IP in your site
It’s pretty common the need for a web application to be able to detect the I.P. address of a client. The I.P. address could be used either for statistic or authentication purposes.
C#
<pre lang="cs">public object ClientIpAddress(HttpRequest myRequest)
{
    string myIP = "";

    if ((string.IsNullOrEmpty(myIP)))
        myIP = myRequest.ServerVariables("HTTP_CLIENT_IP");
    if ((string.IsNullOrEmpty(myIP)))
        myIP = myRequest.ServerVariables("HTTP_X_FORWARDED_FOR");
    if ((string.IsNullOrEmpty(myIP)))
        myIP = myRequest.ServerVariables("HTTP_X_FORWARDED");
    if ((string.IsNullOrEmpty(myIP)))
        myIP = myRequest.ServerVariables("HTTP_X_CLUSTER_CLIENT_IP");
    if ((string.IsNullOrEmpty(myIP)))
        myIP = myRequest.ServerVariables("HTTP_FORWARDED_FOR");
    if ((string.IsNullOrEmpty(myIP)))
        myIP = myRequest.ServerVariables("HTTP_FORWARDED");
    if ((string.IsNullOrEmpty(myIP)))
        myIP = myRequest.ServerVariables("REMOTE_ADDR");

    return myIP;
}


public string Host2Ip(string HostName)
{
    string functionReturnValue = null;
    try {
        System.Net.IPHostEntry myIPs = null;
        myIPs = System.Net.Dns.GetHostEntry(HostName);
        functionReturnValue = myIPs.AddressList[0].ToString();
    } catch (Exception ex) {
        //Handle the error
    }
    return functionReturnValue;
}</pre>
 
Share this answer
 
See a good solution for track Client IP


IP Address to Geolocation
 
Share this answer
 
v2

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