萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> asp.net編程 >> asp.net獲取服務器基本信息的方法代碼

asp.net獲取服務器基本信息的方法代碼

在做網站開發的時候,常常需要獲取,服務器的一些基本信息,怎麼獲取呢,請參閱下面的簡單介紹:   復制代碼 代碼如下:


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

copyright © 萬盛學電腦網 all rights reserved