Show Runtime Info : HttpRuntime « Network « ASP.Net

Home
ASP.Net
1.ADO.net Database
2.Ajax
3.Asp Control
4.Collections
5.Components
6.Data Binding
7.Development
8.File Directory
9.HTML Control
10.Language Basics
11.Login Security
12.Mobile Control
13.Network
14.Page
15.Request
16.Response
17.Server
18.Session Cookie
19.Sitemap
20.Theme Style
21.User Control and Master Page
22.Validation by Control
23.Validation by Function
24.WebPart
25.WPF
26.XML
ASP.Net » Network » HttpRuntime 
Show Runtime Info


<%@ 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();
    }
}

 
Related examples in the same category
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.