ASP.NET aspx获取服务器信息, 操作系统, .NET版本, IIS版本

新建WebApplication, 在aspx页面中写入如下代码
<%@ Page Language="C#" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>

    <%
        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 " + Environment.Version);
        Response.Write("<br/>");
        Response.Write("服务器操作系统版本:" + 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"));
        Response.Write("<br/>");
    %>
</body>
</html>

作者最新文章
C# ASP.NET Core Web Api 与 MVC 模式下 body 参数传递,post 参数方式
C# ASP.NET Framework Web Api 模式下 body 参数传递,post 参数方式
C# 如何创建 NuGet 包(.NET Core SDK)
C# 如何创建 NuGet 包(.NET Framework)
C# .net core 读取json文件,自定义配置文件 appsetting.json