閱讀336 返回首頁    go 阿裏雲 go 技術社區[雲棲]


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

  上一篇:go MFC VS2012對話框背景填圖
  下一篇:go qsort實現排序算法