336
技術社區[雲棲]
ASP.NET 服務器參數、路徑等
using System;
using System.Globalization;
using System.Web.UI;
namespace WebApplication1
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
string test = "";
test += "Request.ServerVariables[\"LOCAL_ADDR\"]:" + Request.ServerVariables["LOCAL_ADDR"] + "<br/>"; //服務器IP地址
test += "Request.ServerVariables[\"SERVER_NAME\"]:" + Request.ServerVariables["SERVER_NAME"] + "<br/>"; //服務器域名
test += "Request.ServerVariables[\"SERVER_SOFTWARE\"]:" + Request.ServerVariables["SERVER_SOFTWARE"] + "<br/>"; //服務器IIS版本
test += "Request.ServerVariables[\"SERVER_PORT\"]:" + Request.ServerVariables["SERVER_PORT"] + "<br/>"; //HTTP訪問端口
test += "Request.ServerVariables[\"APPL_RHYSICAL_PATH\"]:" + Request.ServerVariables["APPL_RHYSICAL_PATH"] + "<br/>"; //虛擬目錄的絕對路徑
test += "Request.ServerVariables[\"PATH_TRANSLATED\"] :" + Request.ServerVariables["PATH_TRANSLATED"] + "<br/>"; //執行文件的絕對路徑
test += "Request.ServerVariables[\"HTTP_HOST\"]:" + Request.ServerVariables["HTTP_HOST"] + "<br/>"; //域名主機
test += "Request.ServerVariables[\"HTTP_ACCEPT_LANGUAGE\"]:" + Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"] + "<br/>"; //服務器區域語言
test += "Request.ServerVariables[\"HTTP_USER_AGENT\"]:" + Request.ServerVariables["HTTP_USER_AGENT"] + "<br/>";
test += "<br/>";
test += "Request.ApplicationPath: " + Request.ApplicationPath + "<br/>";
test += "Request.CurrentExecutionFilePath:" + Request.CurrentExecutionFilePath + "<br/>";
test += "Request.FilePath:" + Request.FilePath + "<br/>";
test += "Request.Path:" + Request.Path + "<br/>";
test += "Request.PhysicalApplicationPath:" + Request.PhysicalApplicationPath + "<br/>";
test += "Request.RawUrl:" + Request.PhysicalApplicationPath + "<br/>";
test += "Request.Url.AbsolutePath: " + Request.PhysicalApplicationPath + "<br/>";
test += "Request.Url.AbsoluteUri:" + Request.PhysicalApplicationPath + "<br/>";
test += "Request.Url.Host:" + Request.PhysicalApplicationPath + "<br/>";
test += "Request.Url.LocalPath:" + Request.PhysicalApplicationPath + "<br/>";
test += "Request.Url.LocalPath:" + Request.PhysicalApplicationPath + "<br/>";
test += "<br/>";
test += "服務器名稱:" + Server.MachineName + "<br/>"; //服務器名稱
test += "CPU個數:" + Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS") + "<br/>"; //CPU個數
test += "CPU類型:" + Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER") + "<br/>"; //CPU類型
test += "虛擬目錄Session總數:" + Session.Contents.Count.ToString(CultureInfo.InvariantCulture) + "<br/>"; //虛擬目錄Session總數
test += "虛擬目錄Application總數:" + Application.Contents.Count.ToString(CultureInfo.InvariantCulture) + "<br/>";//虛擬目錄Application總數
test += ".NET解釋引擎版本:" + ".NET CLR" + Environment.Version.Major + "." + Environment.Version.Minor + "." + Environment.Version.Build + "." + Environment.Version.Revision + "<br/>"; //.NET解釋引擎版本
test += "服務器操作係統版本:" + Environment.OSVersion + "<br/>"; //服務器操作係統版本
Response.Write(test);
}
}
}
輸出結果:

最後更新:2017-04-03 18:52:05
上一篇:
MFC VS2012對話框背景填圖
下一篇:
qsort實現排序算法
2013騰訊編程馬拉鬆初賽
android中各種顏色在drawable.xml的值
Vim??????????????????(1) - ??????vundle????????????-??????-????????????-?????????
RDS for MySQL 空間問題的原因和解決
PostgreSQL 9.5 新特性匯總 [轉]
android 多選聯係人
Docker基礎之一: Docker架構
雲棲社區正式起航!星辰大海,有你有我
oracle錯誤備忘(ORA-00354,ORA-00353和ORA-00312的處理方法)
WebService報錯javax.xml.ws.soap.SOAPFaultException: javax.xml.ws.WebFault.messageName()