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);
        }
    }
}

输出结果:


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值