<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="ShowRuntimeInfo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Runtime Inspector</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:button ID="Button1" runat="server" text="Show HTTP Runtime Properties" onclick="OnShowInfo" />
<asp:button ID="Button2" runat="server" text="Restart the Application" OnClick="Button2_Click" />
<hr>
<asp:Label runat="server" id="TheRuntimeInfo" />
</div>
</form>
</body>
</html>
File: Default.aspx.cs
using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Reflection;
using System.Text;
using System.IO;
public partial class ShowRuntimeInfo : System.Web.UI.Page
{
protected void OnShowInfo(object sender, EventArgs e)
{
DisplayRuntimeInfo();
}
private void DisplayRuntimeInfo()
{
StringBuilder sb = new StringBuilder("");
sb.Append("AppDomainAppId:");
sb.Append(HttpRuntime.AppDomainAppId);
sb.Append("<br/>");
sb.Append("AppDomainAppPath:");
sb.Append(HttpRuntime.AppDomainAppPath);
sb.Append("<br/>");
sb.Append("AppDomainAppVirtualPath:");
sb.Append(HttpRuntime.AppDomainAppVirtualPath);
sb.Append("<br/>");
sb.Append("AppDomainId:");
sb.Append(HttpRuntime.AppDomainId);
sb.Append("<br/>");
sb.Append("Temp ASP.NET Directory");
sb.Append(HttpRuntime.CodegenDir);
sb.Append("<br/>");
Assembly[] listOfAssem = AppDomain.CurrentDomain.GetAssemblies();
sb.Append("<b>Assemblies in the AppDomain</b> (");
sb.Append(listOfAssem.Length.ToString());
sb.Append(")<br/>");
ArrayList list = new ArrayList();
foreach (Assembly a in listOfAssem)
{
try
{
list.Add(Path.GetFileName(a.Location));
}
catch
{
}
}
list.Sort();
sb.Append("<ul>");
foreach (object asm in list)
{
sb.Append("<li>");
sb.Append((string)asm);
sb.Append("</li>");
}
sb.Append("</ul>");
sb.Append("</td></tr></table>");
TheRuntimeInfo.Text = sb.ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
HttpRuntime.UnloadAppDomain();
DisplayRuntimeInfo();
}
}
|