I have created a nice custom installer in VS2010 which not only installs the website to IIS but also does some custom actions like registering COM Dll's and other things. In the process I am also using Microsoft.Web.Administration to do the following:
- Create a custom app pool for the website, with specified .NET Framework version, pipeline mode etc…
- Assign the app pool created to the installed website.
The problem I have is that when I do this:
sm.Sites[0].Applications["/MyNewSite"].ApplicationPoolName = newPool.Name;
sm.CommitChanges();
It appears in code to be assigned and working (i.e no errors) but after the installation, I open up the IIS manager and look at the web application app pool – the app pool is certainly not what I assigned it in code at all. It is just the default app pool however the app pool I created in code is definitely there, with the right details and information.
I DO NOT want to change the website app pool, but the web application. (i.e default website > MyNewSite app pool, NOT /default website)
I have been stumbled by this for over a day and cannot think why it does not work.
what am I doing wrong?
I am installing on a WS2008R2 + all updates box. IIS 7.5.
Thanks
Best Answer
You can try the following code, as created by IIS Manager: