How to programmatically determine if my application is running in IIS 7.0 Integrated Mode on an ASP.NET Page

As a rule, we must control our AppPools and be able to force control of the managed pipeline mode. In my case, I have no control and would like to implement code by code in a slightly different way based on the controlled pipeline mode (Integrated vs Classic). I just don't know how to detect this. Is there an easy way to do this from code by page?

+6
c # iis-7 integrated-pipeline-mode
source share
2 answers

See ApplicationPool.ManagedPipelineMode and ServerManager.ApplicationPools Properties. Thus, you can check the ApplicationPool.ManagedPipelineMode current AppPool approximately like this example, but do it for the ApplicationPool of your application, and not for the default application domain, as in the example. ServerManager.ApplicationPools contains all pools, including yours.

+4
source share

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

+7
source share