title: Change AppPool of Application programmatically
body: <p>I need to change the app pool of all/selected applications under a certain website.
  I got all websites and App Pools on my IIS, but I can't change them.
  Any ideas?</p>
  
  <p>Here's what I've done so far...
  It looks strange to me, because there's only string changing, not object.</p>
  
  <pre><code>private void ChangeAppPool()
  {
      Microsoft.Web.Administration.Site site = (Microsoft.Web.Administration.Site)this.websiteList.SelectedItem;
      Microsoft.Web.Administration.ApplicationPool appPool = (Microsoft.Web.Administration.ApplicationPool)this.appPoolCombo.SelectedItem;
  
      site.Stop();
      site.ApplicationDefaults.ApplicationPoolName = appPool.Name;
  
      foreach (var item in site.Applications)
      {
          item.ApplicationPoolName = appPool.Name;
      }
  
      site.Start();
      appPool.Recycle();
  }
  </code></pre>