如何打印与phpinfo()类似的信息,但用于ASP.NET?

如何打印与phpinfo()类似的信息,但用于ASP.NET?,asp.net,configuration,webserver,phpinfo,Asp.net,Configuration,Webserver,Phpinfo,我在ASP.NET中循环了Request.ServerVariables集合,但它没有phpinfo()那么全面 如何打印ASP.NET的所有信息,包括服务器软件、驱动程序等?快速谷歌结果: 根据他们的说法,答案是否定的。以下可能有效 foreach (string Key in Request.ServerVariables.AllKeys) Response.Write(Key + ": " + Request.ServerVariables[Key] + "<br>"

我在ASP.NET中循环了
Request.ServerVariables
集合,但它没有
phpinfo()
那么全面

如何打印ASP.NET的所有信息,包括服务器软件、驱动程序等?

快速谷歌结果:


根据他们的说法,答案是否定的。

以下可能有效

foreach (string Key in Request.ServerVariables.AllKeys) 
   Response.Write(Key + ": " + Request.ServerVariables[Key] + "<br>");
foreach(Request.ServerVariables.AllKeys中的字符串键)
Response.Write(Key+”:“+Request.ServerVariables[Key]+”
”;

我不确定phpinfo()会给出什么信息。

使用ASP.Net跟踪子系统怎么样?它允许您获得:

控制树:控制树显示一个 ASP.NET的HTML表示形式 控制树。显示每个控件的ID, 运行时类型,它包含的字节数 用于呈现的,以及它所包含的字节数 需要视图中的状态和控件 国家

会话状态:列出会话的所有键 特定用户的会话,其 类型及其值

应用程序状态:列出所有键 在当前应用程序的 应用程序对象及其类型和 价值观

请求Cookies:列出所有Cookies 在页面打开期间传入 请求

响应Cookies:列出所有 在测试过程中传回的cookies 页面的响应

Headers集合:显示所有 过程中可能传入的标头 来自浏览器的请求, 包括接受编码,表示 浏览器是否支持 压缩HTTP响应并接受 语言

表单集合:显示完整的 表单集合的转储和所有 它的键和值

QueryString集合:显示一个 Querystring集合的转储和 它包含的所有键和值

服务器变量:一个完整的 命名所有元素的值对 web服务器知道 应用程序


请参阅。

带有此页眉的空白页应该可以实现以下功能:

<%@ Page Trace="true"  Language="C#" 
    ContentType="text/html" ResponseEncoding="utf-8" %>

我发现了一个答案,乍一看,它似乎涵盖了它涵盖了它: 有人把它写下来了

该项目是一个ASP.Net系统信息探测器。这是一个试图获取尽可能多有用的托管信息的单一页面。这个概念类似于PHP页面,其中包含
phpinfo()

看一看

:客户端对服务器的浏览

Firebug对于客户端来说是什么,Spile对于服务器来说是什么。。。换句话说,客户端可以窥见服务器中发生了什么

这是我的建议。
(来源:)

有,而且有可能。

基本上与
phpinfo()
相同。不仅实际返回的信息非常相似,而且html表示也非常相似


您也可以使用它,即使您只是制作一个纯Web API应用程序,但让控制器返回
HttpResponseMessage
,如下所示:

    public System.Net.Http.HttpResponseMessage Get()
    {
        var serverinfo = System.Web.Helpers.ServerInfo.GetHtml().ToHtmlString();
        var response = new System.Net.Http.HttpResponseMessage();
        response.Content = new System.Net.Http.StringContent("<html><body>" + serverinfo + "</body></html>");
        response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/html");
        return response;
    }
public System.Net.Http.HttpResponseMessage Get()
{
var serverinfo=System.Web.Helpers.serverinfo.GetHtml().ToHtmlString();
var response=new System.Net.Http.HttpResponseMessage();
response.Content=newsystem.Net.Http.StringContent(“+serverinfo+”);
response.Content.Headers.ContentType=new System.Net.Http.Headers.MediaTypeHeaderValue(“text/html”);
返回响应;
}

对于使用VBScript的ASP classic(不是ASP.net-请参阅下面的免责声明),有一个
子aspinfo()
打开,我对其做了非常小的更改(将调用移动到
aspinfo()
并移动顶部作者/注释块)

这是我修改过的版本的源代码,可以在相关Web服务器上保存为
aspinfo.asp

<%@ Language="VBSCRIPT" %>
<%

    '**************************************
    ' Name: aspinfo()
    ' Description:aspinfo() is the equivalent of phpinfo(). It displays all kinds of
    '     information about the server, asp, cookies, sessions and several other things in
    '     a neat table, properly formatted.
    ' By: Dennis Pallett (from psc cd)
    '
    '
    ' Inputs:None
    '
    ' Returns:None
    '
    'Assumes:You can include my code in any of your pages and call aspinfo() to show
    '     the information of your server and asp. 
    '
    '**************************************

Sub aspinfo()
    Dim strVariable, strASPVersion
    Dim strCookie, strKey, strSession
    'Retrieve the version of ASP
    strASPVersion = ScriptEngine & " Version " & ScriptEngineMajorVersion & "." & ScriptEngineMinorVersion
%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <style type="text/css"><!--
    a { text-decoration: none; }
    a:hover { text-decoration: underline; }
    h1 { font-family: arial, helvetica, sans-serif; font-size: 18pt; font-weight: bold;}
    h2 { font-family: arial, helvetica, sans-serif; font-size: 14pt; font-weight: bold;}
    body, td { font-family: arial, helvetica, sans-serif; font-size: 10pt; }
    th { font-family: arial, helvetica, sans-serif; font-size: 10pt; font-weight: bold; }
    //--></style>
    <title>aspinfo()</title></head>
    <body>
    <div align="center">
    <table width="80%" border="0" bgcolor="#000000" cellspacing="1" cellpadding="3">
    <tr>
        <td align="center" valign="top" bgcolor="#FFFFAE" align="left" colspan="2">
            <h3>ASP (<%= strASPVersion %>)</h3>
        </td>
    </tr>
    </table>
    <br>
    <hr>
    <br>
    <h3>Server Variables</h3>
    <table width="80%" border="0" bgcolor="#000000" cellspacing="1" cellpadding="3">
<%
    For Each strVariable In Request.ServerVariables
      Response.write("<tr>")
      Response.write("<th width=""30%"" bgcolor=""#FFFFAE"" align=""left"">" & strVariable & "</th>")
      Response.write("<td bgcolor=""#FFFFD9"" align=""left"">" & Request.ServerVariables(strVariable) & "&nbsp;</td>")
      Response.write("</tr>")
    Next 'strVariable
%>
    </table>
    <br>
    <hr>
    <br>
    <h3>Cookies</h3>
    <table width="80%" border="0" bgcolor="#000000" cellspacing="1" cellpadding="3">
<%
    For Each strCookie In Request.Cookies
        If Not Request.Cookies(strCookie).HasKeys Then
            Response.write("<tr>")
            Response.write("<th width=""30%"" bgcolor=""#FFFFAE"" align=""left"">" & strCookie & "</th>")
            Response.write("<td bgcolor=""#FFFFD9"" align=""left"">" & Request.Cookies(strCookie) & "&nbsp;</td>")
            Response.write("</tr>")
        Else
            For Each strKey In Request.Cookies(strCookie)
                Response.write("<tr>")
                Response.write("<th width=""30%"" bgcolor=""#FFFFAE"" align=""left"">" & strCookie & "(" & strKey & ")</th>")
                Response.write("<td bgcolor=""#FFFFD9"" align=""left"">" & Request.Cookies(strCookie)(strKey) & "&nbsp;</td>")
                Response.write("</tr>")
            Next
        End If
    Next
%>
    </table>
    <br>
    <hr>
    <br>
    <h3>Session Cookies</h3>
    <table width="80%" border="0" bgcolor="#000000" cellspacing="1" cellpadding="3">
<%
    For Each strSession In Session.Contents
            Response.write("<tr>")
            Response.write("<th width=""30%"" bgcolor=""#FFFFAE"" align=""left"">" & strSession & "</th>")
            Response.write("<td bgcolor=""#FFFFD9"" align=""left"">" & Session(strSession) & "&nbsp;</td>")
            Response.write("</tr>")
    Next
%>
    </table>
    <br>
    <hr>
    <br>
    <h3>Other variables</h3>
    <table width="80%" border="0" bgcolor="#000000" cellspacing="1" cellpadding="3">
    <tr><th width="30%" bgcolor="#FFFFAE" align="left">Session.sessionid</th><td bgcolor="#FFFFD9"><%= Session.sessionid %></td></tr>
    <tr><th width="30%" bgcolor="#FFFFAE" align="left">Server.MapPath</th><td bgcolor="#FFFFD9"><%= Server.MapPath ("/") %></td></tr>
    </table>
    </div>
    </body>
    </html>
<%
End Sub
aspinfo()
%>


我实现了一个简单的库,用于包含名为的项目。此库向您显示系统信息、应用程序中包含的程序集、版本号和变更日志


您只需通过nuget将其包含在您的项目中,即可快速集成和自定义。

我有一个方法可以在.net core中添加包含phpinfo类型信息的razor页面…

谢谢,但这是针对经典ASP,而不是ASP.net。actionscript URL已过时。有关经典ASP解决方案,请参见下面的答案。要获得更简洁的输出,请使用
System.Web.Helpers.ServerInfo.GetHtml()
,如下所述: