How does asp.net obtain basic server information?

Source: Internet
Author: User
Tags allkeys servervariables

 

When developing a website, you often need to obtain some basic information about the server. For more information, see the following:

 

 

// Server Name

"Server Name": Server. MachineName

"Server Domain": Request. ServerVariables ["Server_Name"]

"Server Port": Request. ServerVariables ["Server_Port"]

"Web Server Version": Request. ServerVariables ["Server_SoftWare"] // Path

"Virtual Request Path": Request. FilePath

"Physical Request Path": Request. PhysicalPath

"Virtual Application Root Path": Request. ApplicationPath

"Physical Application Root Path": Request. PhysicalApplicationPath // Platform

"Operating System Installation Directory": Environment. SystemDirectory

". Net Version": Environment. Version. ToString ()

". Net Language": System. Globalization. CultureInfo. InstalledUICulture. EnglishName

"Server Current Time": DateTime. Now. ToString ()

"System Uptime": TimeSpan. FromMilliseconds (Environment. TickCount). ToString ()

"Script Timeout": TimeSpan. FromSeconds (Server. ScriptTimeout). ToString ()

// Get Request Headers

// Eg: Connection, Accept, Accept-Charset, Accept-Encoding, Accept-Language, User-Agent...

Foreach (string key in Request. Headers. AllKeys)

{

Request. Headers [key];

}

 

// Get Server Variables

// Eg: ALL_HTTP, ALL_RAW, PATH_INFO, URL...

Foreach (string key in Request. ServerVariables. AllKeys)

{

Request. ServerVariables [key];

}

 

 

 

 

 

 

 

Mainly used classes include Server, Request, and Environment.

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.