使用C#检查应用程序池(IIS 6)的状态 [英] Check the status of an application pool (IIS 6) with C#

查看:387
本文介绍了使用C#检查应用程序池(IIS 6)的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用C#检查IIS6应用程序池的状态? 例如,我想知道它是否正在运行! 预先感谢您的帮助!

How can I check the status of an IIS6 application pool with C# ? For example, I want to know if it is running or not ! Thank's in advance for your help !

推荐答案

http: //msdn.microsoft.com/zh-CN/library/ms524962.aspx

您可以执行以下操作检查AppPoolState属性:

You can do this checking the AppPoolState Property:

 protected void status()
    {
        string appPoolName = "dev.somesite.com";
        string appPoolPath = @"IIS://" + System.Environment.MachineName + "/W3SVC/AppPools/" + appPoolName;
        int intStatus = 0;
        try
        {
            DirectoryEntry w3svc = new DirectoryEntry(appPoolPath);
            intStatus = (int)w3svc.InvokeGet("AppPoolState");
            switch (intStatus)
            {
                case 2:
                    lblStatus.Text = "Running";
                    break;
                case 4:
                    lblStatus.Text = "Stopped";
                    break;
                default:
                    lblStatus.Text = "Unknown";
                    break;
            }
        }

这篇关于使用C#检查应用程序池(IIS 6)的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆