asp.net获取服务器基本信息的方法代码

网络编程 2021-07-04 22:40www.168986.cn编程入门
在做网站开发的时候,常常需要获取,服务器的一些基本信息,怎么获取呢,请参阅狼蚁网站SEO优化的简单介绍
代码如下:

//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,Aept,Aept-Charset,Aept-Encoding,Aept-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 © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by