Summary of methods for ASP. NET to obtain client and server information

Source: Internet
Author: User

This article introduces ASP. NET client and server information retrieval methods. For more information, see.

 

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

Client IP: Page. Request. UserHostAddress;
User information: Page. User;
Server computer name: Page. Server. MachineName;
Current user's computer name: System. Net. Dns. GetHostName ();
Current computer name: System. Environment. MachineName;
Domain Name of the current computer: System. Environment. UserDomainName;
Current computer user: System. Environment. UserName;
Browser type: Request. Browser. Browser;
Browser Id: Request. Browser. Id;
Browser Version: Request. Browser. Version;
Whether the Browser is a test version: Request. Browser. Beta;
Browser resolution (pixel): Request ["width"]. ToString () + "*" + Request ["height"]. ToString

(); // 1280*1024
Client operating system: Request. Browser. Platform;
Is it a win16 system: Request. Browser. Win16;
Win32 system: Request. Browser. Win32;

Server Information:

Server computer name: "http: //" + HttpContext. Current. Request. Url. Host +

HttpContext. Current. Request. ApplicationPath;

Server IIS Version: Request. ServerVariables ["Server_SoftWare"]. ToString ();

Server Domain Name: Request. ServerVariables ["SERVER_NAME"]. ToString ();

Server port: Request. ServerVariables ["Server_Port"]. ToString ();

Server IP Address: Request. ServerVariables ["LOCAl_ADDR"]

Server script timeout time: (Server. ScriptTimeout/1000). ToString () + "second ";

Server Operating System: Environment. OSVersion. ToString ();

The folder where this file is located: Request. PhysicalApplicationPath;

Server IE version: Registry. LocalMachine. OpenSubKey (@ "SOFTWAREMicrosoftInternet

ExplorerVersion Vector). GetValue ("IE", "not detected"). ToString ();

System Folder: Environment. SystemDirectory. ToString ();

Current server time: DateTime. Now. ToString ();

Language type of the server: CultureInfo. InstalledUICulture. EnglishName;

The last time the server was started to the current running time: (Environment. TickCount/0x3e8)/60). ToString () + "minute

";

CPU type: Environment. GetEnvironmentVariable ("PROCESSOR_IDENTIFIER"). ToString ();

Logical drive: string [] achDrives = Directory. GetLogicalDrives ();
For (int I = 0; I <Directory. GetLogicalDrives (). Length-1; I ++)
{
AchDrives [I]. ToString ();
}

Total CPU: Environment. GetEnvironmentVariable ("NUMBER_OF_PROCESSORS"). ToString ();

Virtual Memory: (Environment. WorkingSet/1024). ToString () + "M ";

. NET Framework Version: string. Concat (new object [] {Environment. Version. Major, ".",

Environment. Version. Minor, Environment. Version. Build, ".", Environment. Version. Revision

});

CPU occupied by Asp.net: (TimeSpan) Process. GetCurrentProcess

(). TotalProcessorTime). TotalSeconds. ToString ("N0 ″);

Memory occupied by Asp.net: (Double) Process. GetCurrentProcess (). WorkingSet64/1048576). ToString ("N2

") +" M ";

Current Session Count: Session. Contents. Count. ToString ();

Current program memory usage: (Double) GC. GetTotalMemory (false)/1048576). ToString ("N2") + "M ";

Current SessionID: Session. Contents. SessionID;

Current System UserName: 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.