如何以编程方式检测我的应用程序是否在ASP.NET页面中的IIS 7.0集成模式下运行

时间:2022-07-13 03:35:45

Generally we should have control of our AppPools and be able to force the Managed Pipeline Mode. In my case I don't have control and would like to implement the code behind code a little differently based on the Managed Pipeline Mode (Integrated vs Classic). I just don't know how to detect this. Is there a simple way to do it from within the code behind page?

通常我们应该控制我们的AppPools并能够强制管理管道模式。在我的情况下,我没有控制权,并希望根据托管流水线模式(集成与经典)实现代码背后的代码。我只是不知道如何检测到这一点。有没有一种简单的方法可以在页面后面的代码中执行此操作?

2 个解决方案

#1


4  

Look at ApplicationPool.ManagedPipelineMode and ServerManager.ApplicationPools Properties. So you can examine ApplicationPool.ManagedPipelineMode of the current AppPool about like this example do, but to do this for ApplicationPool of your application and not for the default application domain like the example do. The ServerManager.ApplicationPools contain all pools including yours one.

查看ApplicationPool.ManagedPipelineMode和ServerManager.ApplicationPools属性。因此,你可以检查当前AppPool的ApplicationPool.ManagedPipelineMode,就像这个例子那样,但要为你的应用程序的ApplicationPool执行此操作,而不是像示例那样执行默认应用程序域。 ServerManager.ApplicationPools包含所有池,包括您的池。

#2


8  

I found a way in .NET 4.0 to do this without referencing the Microsoft.Web.Administration assembly. The System.Web.HttpRuntime class has the UsingIntegratedPipeline boolean property.

我在.NET 4.0中找到了一种方法,可以在不引用Microsoft.Web.Administration程序集的情况下执行此操作。 System.Web.HttpRuntime类具有UsingIntegratedPipeline布尔属性。

#1


4  

Look at ApplicationPool.ManagedPipelineMode and ServerManager.ApplicationPools Properties. So you can examine ApplicationPool.ManagedPipelineMode of the current AppPool about like this example do, but to do this for ApplicationPool of your application and not for the default application domain like the example do. The ServerManager.ApplicationPools contain all pools including yours one.

查看ApplicationPool.ManagedPipelineMode和ServerManager.ApplicationPools属性。因此,你可以检查当前AppPool的ApplicationPool.ManagedPipelineMode,就像这个例子那样,但要为你的应用程序的ApplicationPool执行此操作,而不是像示例那样执行默认应用程序域。 ServerManager.ApplicationPools包含所有池,包括您的池。

#2


8  

I found a way in .NET 4.0 to do this without referencing the Microsoft.Web.Administration assembly. The System.Web.HttpRuntime class has the UsingIntegratedPipeline boolean property.

我在.NET 4.0中找到了一种方法,可以在不引用Microsoft.Web.Administration程序集的情况下执行此操作。 System.Web.HttpRuntime类具有UsingIntegratedPipeline布尔属性。