ASP. NET A simple way to get server and client computer names

  • 2021-08-05 09:39:53
  • OfStack

This article illustrates how ASP. NET simply obtains server and client computer names. Share it for your reference, as follows:


// Get the server computer name 
string serverPCName = System.Net.Dns.GetHostName();
// Get the client computer name 
System.Net.IPAddress clientIP = System.Net.IPAddress.Parse(Request.UserHostAddress);// According to the goal IP Address acquisition IP Object 
System.Net.IPHostEntry ihe = System.Net.Dns.GetHostEntry(clientIP);// According to IP Object to create a host object 
string clientPCName=ihe.HostName;// Get the client host name 

For more readers interested in asp. net, please check the topics of this site: "Summary of asp. net Operation json Skills", "Summary of asp. net String Operation Skills", "Summary of asp. net Operation XML Skills", "Summary of asp. net File Operation Skills", "Summary of asp. net ajax Skills" and "Summary of asp. net Cache Operation Skills".

I hope this article is helpful to everyone's asp. net programming.


Related articles: