Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
(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?
Posted

Hi

You can refer the below link for details on adding Microsoft.Web.Administration dll

http://stackoverflow.com/questions/18104151/how-to-reference-microsoft-web-administration[^]

Implementation of ApplicationPool methods

http://msdn.microsoft.com/en-us/library/microsoft.web.administration.applicationpool(v=vs.90).aspx[^]
 
Share this answer
 
C#
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
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900