简体   繁体   中英

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).
I use VS 2012 in Windows 8.1.
I use ASP.NET 4.5. .NET 4.5.1 in my project csproj.

Programmatically How-to know if Application Pool mode is Classic or Integrated ?

U need to use the Microsoft.Web.Administration namespace. You can get this from NuGet or from %WinDir%\\System32\\InetSrv\\Microsoft.Web.Administration.dll

With the ServerManager class you can get the applicationpool you need. the property on the applicationpool you're looking for is 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 - Integrated - The managed pipeline runs in Integrated mode.

1 - Classic - The managed pipeline runs in ISAPI mode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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