asp.net method code to get basic information about the server

Source: Internet
Author: User
Tags foreach allkeys current time servervariables server port
In doing website development, often need to get, the server's some basic information, how to get it, see the following brief introduction: copy Code code as follows:


//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];
 }

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.