1
I need to get the ip and name of the client’s local machine in case the user who will be accessing my system.
My system is hosted on the network system and database. The commands I have used so far I get the server name and the server ip, but I need to know that the user is accessing the system from inside our office.
MYSQL database, I’ve used several commands, but already deleted I’ll put the last two I’m 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]);
Any language ?
– David
Asp.net is not language. It is C#?
– user28595
infome which database you are using, and there you speak C# Asp.net, but you need to know more. It could be webforms, it could be mvc or even Asp.net core. If possible, place an excerpt of your code where you would like to take this data
– Rovann Linhalis
I have now used the following commands: For the host name = System.Net.Dns.Gethostentry(Request.Servervariables["remote_host"]). Hostname; and gave this result = b39f88fe.virtua.com.br
– Alexandre S Gaeta
and used the command, public Static string Getpublicip() { string url = "http://checkip.dyndns.org"; System.Net.Webrequest req = System.Net.Webrequest.Create(url); System.Net.Webresponse Resp = req.Getresponse(); System.IO.Streamreader sr = new System.IO.Streamreader(Resp.Getresponsestream()); string Response = sr.Readtoend(). Trim(); string[] a = Split(':'); string a2 = a[1]. Substring(1); string[] A3 = a2.Split('<'); string A4 = A3[0]; Return A4; }
– Alexandre S Gaeta
ip = Getpublicip(); and the result is this = 187.84.230.84
– Alexandre S Gaeta