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;