Capture the IP and local machine name

0

I need to get the ip and local machine name of the client in case the user who will be accessing my system.

My system is hosted on the system's network and database. The commands I've used so far I get the server name and server ip, but I need to know that the user is accessing the system from within our office.

MYSQL database, I have already used several commands, but I have already deleted the last two that I am using below:

string[] computer_name = System.Net.Dns.GetHostEntry(Request.ServerVariables["remote_host"]).HostName.Split(new Char[] { '.' });
        String ecn = System.Environment.MachineName;                                  
        string vNomeMaquina = computer_name[0].ToString();


    string Ip;

        System.Net.IPHostEntry v_ipMaquina = System.Net.Dns.Resolve(vNomeMaquina);
        System.Net.IPAddress[] address = v_ipMaquina.AddressList;
        for (int i = 0; i < address.Length; i++) //ciclo q escreve o ip
            Ip = (Ip + address[i]);
    
asked by anonymous 14.03.2018 / 14:10

1 answer

1

You can access the user's IP through HttpContext with the following code:

HttpContext.Current.Request.UserHostAddress

Now the local machine name through C # is not possible due to security issues.

    
14.03.2018 / 14:16