How to print similar information as phpinfo() but

2019-01-17 16:49发布

I've looped over the Request.ServerVariables collection in ASP.NET, but it's not as comprehensive as phpinfo().

How can I print all that information, including server software, drivers, etc, for ASP.NET?

10条回答
Ridiculous、
2楼-- · 2019-01-17 17:20

ServerInfo.GetHtml() is basically the same as phpinfo(). Not only is the actual returned information extremely similar but also the html presentation. Here is a live demo!


You can also use it even if you're only making a pure Web API app, but letting a controller return a HttpResponseMessage like so:

    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;
    }
查看更多
再贱就再见
3楼-- · 2019-01-17 17:22

here is an answer i found, that looks like it covers it covers it, at first sight: http://www.actionscript.org/forums/showthread.php3?p=133347 someone scripted it out

查看更多
劳资没心,怎么记你
4楼-- · 2019-01-17 17:27

I realized a simple library to inlude in projects called InfoPage. This library show you system info, assembly included in application, build number,and changelogs.

You can simply include it in your project by nuget, it is quick to integrate and customizable.

查看更多
相关推荐>>
5楼-- · 2019-01-17 17:30

How about using the ASP.Net tracing subsystem? It allows you to get:

Control Tree: Control tree presents an HTML representation of the ASP.NET Control Tree. Shows each control's ID, run time type, the number of bytes it took to be rendered, and the bytes it requires in View State and Control State.

Session State: Lists all the keys for a particular user's session, their types and their values.

Application State: Lists all the keys in the current application's Application object and their type and values.

Request Cookies: Lists all the cookies passed in during the page is requested.

Response Cookies: Lists all the cookies that were passed back during the page's response.

Headers Collection: Shows all the headers that might be passed in during the request from the browser, including Accept-Encoding, indicating whether the browser supports the compressed HTTP responses and Accept languages.

Form Collection: Displays a complete dump of the Form Collection and all its keys and values.

QueryString Collection: Displays a dump of the Querystring collection and all its contained keys and values.

Server Variables: A complete dump of name-value pairs of everything that the web server knows about the application.

See here.

查看更多
登录 后发表回答