ASP. NET Server Information Retrieval

Source: Internet
Author: User

<P> Server IP address: <% = request. servervariables ["local_addr"] %> </P>
<P> server name: <% = request. servervariables ["SERVER_NAME"] %> </P>
<P> http port: <% = request. servervariables ["server_port"] %> </P>
<P> server time: <% = datetime. Now %> </P>
<P> operating system information: <% = request. servervariables ["http_user_agent"] %> </P>
<P> allowed files: <% = request. servervariables ["http_accept"] %> </P>
<P> virtual directory: <% = httpcontext. Current. Request. applicationpath %> </P>
<P> physical path: <% = httpruntime. appdomainapppath %> </P>
<P> probe file path: <% = context. server. mappath (request. servervariables ["script_name"]) %> </P>
<P> script Timeout: <% = server. scripttimeout %> (seconds) </P>
<P> Number of CPUs: <% = environment. getenvironmentvariable ("number_of_processors") %> </P>

String serveros = environment. osversion. tostring ();
String cpusum = environment. getenvironmentvariable ("number_of_processors"); // Number of CPUs:
String cputype = environment. getenvironmentvariable ("processor_identifier"); // CPU type:
String serversoft = request. servervariables ["server_software"]; // information service software:
String machinename = server. machinename; // server name
String servername = request. servervariables ["SERVER_NAME"]; // server Domain Name
String serverpath = request. servervariables ["appl_physical_path"]; // virtual service absolute path
String servernet = ". Net CLR" + environment. version. tostring (); // DOTNET version
String serverarea = (datetime. Now-datetime. utcnow). totalhours> 0? "+" + (Datetime. Now-datetime. utcnow). totalhours. tostring (): (datetime. Now-datetime. utcnow). totalhours. tostring (); // server time zone
String servertimeout = server. scripttimeout. tostring (); // script timeout
String serverstart = (double) system. environment. tickcount/3600000). tostring ("N2"); // start time
// ASPnet CPU time
String serversessions = session. Contents. Count. tostring (); // The total number of sessions.
String serverapp = application. Contents. Count. tostring (); // total number of applications
String servercache = cache. Count. tostring (); // The total number of application caches.
// Memory occupied by applications
// String serverfso = check ("scripting. FileSystemObject"); // read and write FSO text files
String servertimeout = server. scripttimeout. tostring () + "millisecond"; // execution time on the current page

Http_user_agent: Obtain the browser type and version used by the user.

Remote_addr

Request_method

Local_addr

SERVER_NAME: Obtain the server host name

Path_info: Obtain the virtual path of the current executable program

Path_translated: Obtain the absolute path of the current execution Program

Content_length obtains the total number of characters sent by the request program.

Content_type

Gateway_interface

QUERY_STRING get additional URL Information

Script_name: get the file name of the current program (including the Virtual Path)

Server_port: gets the port from which the server accepts the request.

Server_protocol: Obtain the protocol and version number that the server complies.

Http_accept_language: gets the language used by the user.

Using system;
Using system. Data;
Using system. configuration;
Using system. collections;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;

Public partial class adminlogin_default: system. Web. UI. Page
{
# Required designer variables for Region
Protected string membername, adminlevel;
Protected string serveros, cpusum, cputype, serversoft, machinename, servername, serverpath, servernet, serverarea, servertimeout, serverstart;
Protected string prstart, aspnetn, aspnetcpu, serversessions, serverapp, servercache, serverappn, serverfso, runtime;
# Endregion

Protected void page_load (Object sender, eventargs E)
{
Dataload ();
}

# Region obtaining server and user information
Private void dataload ()
{
Datetime stime = datetime. now;

Serveros = environment. osversion. tostring (); // operating system:
Cpusum = environment. getenvironmentvariable ("number_of_processors"); // Number of CPUs:
Cputype = environment. getenvironmentvariable ("processor_identifier"); // CPU type:
Serversoft = request. servervariables ["server_software"]; // information service software:
Machinename = server. machinename; // server name
Servername = request. servervariables ["SERVER_NAME"]; // server Domain Name
Serverpath = request. servervariables ["appl_physical_path"]; // virtual service absolute path
Servernet = ". Net CLR" + environment. version. tostring (); // DOTNET version
Serverarea = (datetime. Now-datetime. utcnow). totalhours> 0? "+" + (Datetime. Now-datetime. utcnow). totalhours. tostring (): (datetime. Now-datetime. utcnow). totalhours. tostring (); // server time zone
Servertimeout = server. scripttimeout. tostring (); // script timeout
Serverstart = (double) system. environment. tickcount/3600000). tostring ("N2"); // start time
Prstart = getprstart (); // process start time
Aspnetn = getaspnetn (); // ASPnet memory usage
Aspnetcpu = getaspnetcpu (); // ASPnet CPU time
Serversessions = session. Contents. Count. tostring (); // The total number of sessions.
Serverapp = application. Contents. Count. tostring (); // total number of applications
Servercache = cache. Count. tostring (); // total number of application caches
Serverappn = getserverappn (); // memory occupied by the application
Serverfso = check ("scripting. FileSystemObject"); // read and write FSO text files
Servertimeout = server. scripttimeout. tostring () + "millisecond"; // execution time on the current page
If (serversoft = "")
{
Serversoft = "NONE ";
}

# Required content for Region page Initialization
Header. Title = "Shen Zilong" + "-system management ";
// Headertextinfo. Initialization ();
// Headertextinfo. getadminheader (this, null );
# Endregion

# Region webcontrols config
// Viewstate config
This. enableviewstate = false;
# Endregion

// Execution time
Datetime etime = datetime. now;
Runtime = (etime-stime). totalmilliseconds). tostring ();
}
# Endregion

# Region obtaining Server System Information
Private string getserverappn ()
{
String temp;
Try
{
Temp = (double) GC. gettotalmemory (false)/1048576). tostring ("N2") + "M ";
}
Catch
{
Temp = "unknown ";
}
Return temp;
}

Private string getaspnetn ()
{
String temp;
Try
{
Temp = (double) system. Diagnostics. process. getcurrentprocess (). workingset64/1048576). tostring ("N2") + "M ";
}
Catch
{
Temp = "unknown ";
}
Return temp;
}

Private string getaspnetcpu ()
{
String temp;
Try
{
Temp = (timespan) system. Diagnostics. process. getcurrentprocess (). totalprocessortime). totalseconds. tostring ("N0 ");
}
Catch
{
Temp = "unknown ";
}
Return temp;
}

Private string getprstart ()
{
String temp;
Try
{
Temp = system. Diagnostics. process. getcurrentprocess (). starttime. tostring ();
}
Catch
{
Temp = "unknown ";
}
Return temp;
}

Private string check (string OBJ)
{
Try
{
Object claobj = server. Createobject (OBJ );
Return "supported ";
}
Catch
{
Return "not supported ";
}
}
# Endregion
}

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.