现在的位置: 首页 > 综合 > 正文

ASP.NET 服务器参数、路径等

2013年10月22日 ⁄ 综合 ⁄ 共 2655字 ⁄ 字号 评论关闭
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);
        }
    }
}

输出结果:

抱歉!评论已关闭.