ASP.Net 获取服务器信息
1: Response.Write("服务器机器名:" + Server.MachineName);
2: Response.Write("<br/>");
3: Response.Write("服务器IP地址:" + Request.ServerVariables["LOCAL_ADDR"]);
4: Response.Write("<br/>");
5: Response.Write("服务器域名:" + Request.ServerVariables["SERVER_NAME"]);
6: Response.Write("<br/>");
7: Response.Write(".NET解释引擎版本:" + ".NET CLR" + System.Environment.Version);
8: Response.Write("<br/>");
9: Response.Write("服务器操作系统版本:" + System.Environment.OSVersion.ToString());
10: Response.Write("<br/>");
11: Response.Write("服务器IIS版本:" + Request.ServerVariables["SERVER_SOFTWARE"]);
12: Response.Write("<br/>");
13: Response.Write("HTTP访问端口:" + Request.ServerVariables["SERVER_PORT"]);
14: Response.Write("<br/>");
15: Response.Write("虚拟目录的绝对路径:" + Request.ServerVariables["APPL_RHYSICAL_PATH"]);
16: Response.Write("<br/>");
17: Response.Write("执行文件的绝对路径:" + Request.ServerVariables["PATH_TRANSLATED"]);
18: Response.Write("<br/>");
19: Response.Write("Session总数:" + Session.Contents.Count.ToString());
20: Response.Write("<br/>");
21: Response.Write("Application总数:" + Application.Contents.Count.ToString());
22: Response.Write("<br/>");
23: Response.Write("缓存Cache总数:" + Cache.Count.ToString());
24: Response.Write("<br/>");
25: Response.Write("服务器主机:" + Request.ServerVariables["HTTP_HOST"]);
26: Response.Write("<br/>");
27: Response.Write("服务器区域语言:" + Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"]);
28: Response.Write("<br/>");
29: Response.Write("访客信息:" + Request.ServerVariables["HTTP_USER_AGENT"]);
30: Response.Write("<br/>");
31: Response.Write("服务器CPU个数:" + System.Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS"));
32: Response.Write("<br/>");
33: Response.Write("服务器CPU类型:" + System.Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER"));
你也许会问 HTTP_HOST 和 SERVER_NAME 的值是一样的,它们之间有什么区别?
通常服务器默认端口为80,HTTP_HOST将省略不显示端口号。如果服务器是非80端口,则HTTP_HOST显示端口号。
简单的说就是: HTTP_HOST = SERVER_NAME:SERVER_PORT
专注互联网开发的:斯通麦博