title: ServerManager CommitChanges makes changes with a slight delay
body: <p>i have a little problem with the ServerManager class (from the Microsoft.Web.Administration assembly) and i hope some of you can help me out.</p>
  
  <p>Basically I need to create a new application inside a site (using IIS 7.5) and redirect the user to the new application, inside the same event.This functionality is implemented inside a .net web app using mvc 3/c#.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>ServerManager iisManager = new ServerManager();
  Site mySite = iisManager.Sites["mySitesName"];            
  ApplicationCollection applications = mySite.Applications;
  
  Application app = applications.Add(newapp, physicalPath);
  app.ApplicationPoolName = "myAppPool";
  
  iisManager.CommitChanges();                    
  iisManager.Dispose();
  
  return new RedirectResult("http://localhost/" + newapp);
  </code></pre>
  
  <p>I think the problem with this code is that ServerManager seems to submit changes with a slight delay and the redirect to the newly added application in IIS returns "HTTP Error 404.0 - Not Found" because the changes commited from ServerManager are not finished (i think). If I refresh the page after the 404, the new application loads.</p>
  
  <p>Any help or idea is greatly appreciated.</p>
  
  <p>Cheers!</p>