Programming against IIS Application pools in SharePoint

Earlier versions of SharePoint did make some use of the .NET Framework, but SharePoint 2007 has been rebuilt from ground up on top of it, meaning SharePoint applications are in fact tremendously powerful ASP.NET applications.

What are Application Pools?
A classic example that I always utilize to discuss application pools is a web hosting company that hosts many websites on a common server, and therefore all the websites hosted on this server share the system resources. If one of the hosted websites had a memory leak, this potentially takes memory away from the other hosted sites, causing errors and inconveniences.
Prior to IIS 6.0, at least, that was the case. Too many server resources were shared between websites, and it was too easy for an error to creep in and damage the entire server process.

Fortunately, IIS 6.0 introduced a new concept called application pools. Application pools form boundaries around applications, separating them from each other even though they are being hosted on the same server.

Each application pool is given its own set of server resources (including memory). That way, the hosting company can now host each website in its own application pool to accomplish security, reliability, and availability and to prevent the leaky or misbehaving site from affecting other sites.

Application Pools in SharePoint Object Model

The SharePoint OM comprises types whose instances correspond to IIS entities such as application pools, web sites,…. These types permit you to program against these entities within your code

SharePoint represents each IIS application pool with an instance of a type named SPApplicationPool, which allows you to program against IIS application pools from your managed code. Here are some of the public methods of the SPApplicationPool class that you can use in your managed code:

  • Provision. This method creates the application pool.
  • Unprovision. This method removes the application pool.
  • Update. This method updates and commits the changes made to the application pool.
  • UpdateCredentials. This method updates and commits the credentials under which the
    application pool is running.
   1:  SPWebServiceCollection wsc = new SPWebServiceCollection(SPFarm.Local);
   2:  foreach (SPWebService ws in wsc)
   3:  {
   4:       SPApplicationPoolCollection appPoolCollection= ws.ApplicationPools;
   5:       foreach (SPApplicationPool appPool in appPoolCollection)
   6:       {
   7:           // Your code
   8:       }
   9:  }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s