简体   繁体   English

在ASP.NET 4.5中以编程方式获取模式应用程序池

[英]Get mode Application Pool programmatically in ASP.NET 4.5

I am running IIS 7.5 Under Windows 2008 R2 (I use Windows 8.1 in development). 我正在Windows 2008 R2下运行IIS 7.5(我在开发中使用Windows 8.1)。
I use VS 2012 in Windows 8.1. 我在Windows 8.1中使用VS 2012。
I use ASP.NET 4.5. 我使用ASP.NET 4.5。 .NET 4.5.1 in my project csproj. 我的项目csproj中的.NET 4.5.1。

Programmatically How-to know if Application Pool mode is Classic or Integrated ? 以编程方式 如何知道“应用程序池”模式是“ 经典”还是“集成”

U need to use the Microsoft.Web.Administration namespace. 您需要使用Microsoft.Web.Administration命名空间。 You can get this from NuGet or from %WinDir%\\System32\\InetSrv\\Microsoft.Web.Administration.dll 您可以从NuGet或%WinDir%\\ System32 \\ InetSrv \\ Microsoft.Web.Administration.dll中获得此文件

With the ServerManager class you can get the applicationpool you need. 使用ServerManager类,可以获取所需的applicationpool。 the property on the applicationpool you're looking for is ManagedPipelineMode . 您要查找的applicationpool上的属性是ManagedPipelineMode

var serverManager = new ServerManager();
var appPool = serverManager.ApplicationPools[0]; // get appPool by Index or by appPoolName
var managedPipelineMode = appPool.ManagedPipelineMode;

The return value can either be 0 or 1: 返回值可以是0或1:

0 - Integrated - The managed pipeline runs in Integrated mode. 0-集成-受管管道以集成模式运行。

1 - Classic - The managed pipeline runs in ISAPI mode. 1-经典-托管管道以ISAPI模式运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM