In. NET to get a computer name, IP address and the current user name is very simple, the following is a few of my common methods, if you have other good methods, you can reply together to organize: 1. Private properties in asp: Get Server computer name: Page.Server.ManchineName Get user information: Page.User get the client computer name: Page.Request.UserHostName Get client PC IP:Page.Request.UserHostAddress 2. Common methods in Network programming: Get the current computer name: Static System.Net.Dns.GetHostName () remove all IP addresses according to the computer name: Static System.Net.Dns.Resolve (computer name). AddressList can also take out the computer name according to the IP address: static System.Net.Dns.Resolve (IP address). HostName 3. Common properties of the system environment class: Current computer name: Static System.Environment.MachineName the current computer belongs to domain: static System.Environment.UserDomainName Current PC User: static System.Environment.UserNameRequest.UserHostAddressstring IP = (request.servervariables["Http_via"]!= NULL)? request.servervariables["Http_x_forwarded_for"]. ToString (): request.servervariables["REMOTE_ADDR"]. ToString (); string ipAddress = System.Web.HttpContext.Current.Request.UserHostAddress; Reference namespace first: using System.Net; Get the client IP address: request.servervariables["REMOTE_ADDR"] or rqurest.userhostaddress (); Get the native IP address: request.servervariables["local_addr"] or addr = new SYstem.Net.IPAddress (Dns.gethostbyname (Dns.gethostname ()). AddressList [0]. Address); HttpBrowserCapabilities bc= Request.Browser; LABEL3.TEXT=BC. Browser+ "" +BC. version;//get Browser version LABEL2.TEXT=BC. platform;//Get operating system hostname=dns.gethostname (); Iphostentry Jj=dns.gethostbyname (hostname);//Get IP//ipaddress ip=dns.resolve (hostname); Label1.text=jj. Addresslist[0]. ToString ();
. NET to get the IP address