问题描述
(幕后:我正在尝试增加应用程序池 - >空闲超时。)
我想添加我的C#&中的ApplicationPool 类使用VS 2013和ASP的ASP.Net项目IIS Express。我无法添加 ApplicationPool 类的引用。我认为是,Microsoft.Web.Administration;被列入参考文献。但是根本找不到这个。
我想知道为什么我不能在ASP.Net中添加 ApplicationPool 类的引用, C#?
或任何其他更改应用程序池的方法 - >以编程方式空闲超时?
(Behind the scene: I am trying to increase the application pool-> Idle time-out.)
I am trying to add the ApplicationPool class in my C# & ASP.Net project using VS 2013 & IIS Express. I cannot add the reference for the ApplicationPool class. I assume it is, Microsoft.Web.Administration; to be included in the reference. But couldn't locate this at all.
I want to know how why I cannot add the reference for ApplicationPool class in ASP.Net, C#?
Or any other ways to change the application pool-> Idle time-out programmatically?
推荐答案
public ArrayList GetApplicationPoolCollection()
{
// Use an ArrayList to transfer objects to the client.
ArrayList arrayOfApplicationBags = new ArrayList();
ServerManager serverManager = new ServerManager();
ApplicationPoolCollection applicationPoolCollection = serverManager.ApplicationPools;
foreach (ApplicationPool applicationPool in applicationPoolCollection)
{
PropertyBag applicationPoolBag = new PropertyBag();
applicationPoolBag[ServerManagerDemoGlobals.ApplicationPoolArray] = applicationPool;
arrayOfApplicationBags.Add(applicationPoolBag);
// If the applicationPool is stopped, restart it.
if (applicationPool.State == ObjectState.Stopped)
{
applicationPool.Start();
}
// Set the CPU limit to a maximum of 25.
if (applicationPool.Cpu.Limit > 25)
{
applicationPool.Cpu.Limit = 25;
}
// Set the process model max process to 1 to prohibit Web Garden
if (applicationPool.ProcessModel.MaxProcesses > 1)
{
applicationPool.ProcessModel.MaxProcesses = 1;
}
// Set the recycling time to a maximum of one day (1440 minutes).
if (applicationPool.Recycling.PeriodicRestart.Time.TotalMinutes > 1440)
{
applicationPool.Recycling.PeriodicRestart.Time = TimeSpan.FromMinutes(1440);
}
}
// CommitChanges to persist the changes to the ApplicationHost.config.
serverManager.CommitChanges();
return arrayOfApplicationBags;
}
codeblock
codeblock
这篇关于使用C#修改IIS Express-ApplicationPool?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!