How to obtain IP/user name and other information

Source: Internet
Author: User

In. NET, it is very easy to get a computer name, IP address and current user name. The following are some of my frequently used methods. If you have other good methods, you can reply to them:

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.