首頁  >  文章  >  後端開發  >  asp.net 取得伺服器信息

asp.net 取得伺服器信息

伊谢尔伦
伊谢尔伦原創
2016-11-25 09:34:531257瀏覽

Response.Write("服务器机器名:" + Server.MachineName);
Response.Write("<br/>");
Response.Write("服务器IP地址:" + Request.ServerVariables["LOCAL_ADDR"]);
Response.Write("<br/>");
Response.Write("服务器域名:" + Request.ServerVariables["SERVER_NAME"]);
Response.Write("<br/>");
Response.Write(".NET解释引擎版本:" + ".NET CLR" + System.Environment.Version);
Response.Write("<br/>");
Response.Write("服务器操作系统版本:" + System.Environment.OSVersion.ToString());
Response.Write("<br/>");
Response.Write("服务器IIS版本:" + Request.ServerVariables["SERVER_SOFTWARE"]);
Response.Write("<br/>");
Response.Write("HTTP访问端口:" + Request.ServerVariables["SERVER_PORT"]);
Response.Write("<br/>");
Response.Write("虚拟目录的绝对路径:" + Request.ServerVariables["APPL_RHYSICAL_PATH"]);
Response.Write("<br/>");
Response.Write("执行文件的绝对路径:" + Request.ServerVariables["PATH_TRANSLATED"]);
Response.Write("<br/>");
Response.Write("Session总数:" + Session.Contents.Count.ToString());
Response.Write("<br/>");
Response.Write("Application总数:" + Application.Contents.Count.ToString());
Response.Write("<br/>");
Response.Write("缓存Cache总数:" + Cache.Count.ToString());
Response.Write("<br/>");
Response.Write("服务器主机:" + Request.ServerVariables["HTTP_HOST"]);
Response.Write("<br/>");
Response.Write("服务器区域语言:" + Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"]);
Response.Write("<br/>");
Response.Write("访客信息:" + Request.ServerVariables["HTTP_USER_AGENT"]);
Response.Write("<br/>");
Response.Write("服务器CPU个数:" + System.Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS"));
Response.Write("<br/>");
Response.Write("服务器CPU类型:" + System.Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER"));

你也許會問 HTTP_HOST 和 SERVER_NAME 的值是一樣的,它們之間有什麼差別?
通常伺服器預設連接埠為80,HTTP_HOST將省略不顯示連接埠號碼。如果伺服器是非80端口,則HTTP_HOST顯示端口號。
簡單的說就是: HTTP_HOST = SERVER_NAME:SERVER_PORT

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn