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
http://code.google.com/p/aspnetsysinfo/
The project is a ASP.Net System Information Prober. It's a single page which trying to get as much as possible of useful hosting information. The concept is similar to PHP page which contains
phpinfo()
...
The following might work?
foreach (string Key in Request.ServerVariables.AllKeys)
Response.Write(Key + ": " + Request.ServerVariables[Key] + "<br>");
I'm not sure what info phpinfo() spits out.
Quick google result:
http://forums.asp.net/p/901862/2087653.aspx
According to them, the answer is no.
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.
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;
}