1. Special attributes in asp. Net:
Get server computer name: page. server. manchinename
Get user information: page. user
Obtain the client computer name: page. request. userhostname
Obtain the Client ip Address: page. request. userhostaddress
2. General methods in network programming:
Get the current computer name: static system. Net. dns. gethostname ()
Retrieve all IP addresses based on the computer name: static system. Net. dns. resolve (computer name). addresslist
You can also obtain the computer name static system. Net. dns. resolve (IP address). hostname Based on the IP address.
3. General attributes of the system environment:
Current computer name: static system. environment. machinename
Domain Name of the current computer: static system. environment. userdomainname
Current computer user: static system. environment. username
For example:
Using system. Net;
Private void buttonip_click (object sender, system. eventargs e)
{
System. Net. ipaddress [] addresslist = dns. gethostbyname (dns. gethostname (). addresslist;
If (addresslist. length> 1)
{
Textlip. text = addresslist [0]. tostring ();
Textsip. text = addresslist [1]. tostring ();
}
Else
{
Textlip. text = addresslist [0]. tostring ();
Textsip. text = "no available connections ";
}
}