Tuesday, December 1, 2009

Deploying on IIS7

Have you ever written code to deploy on IIS 6? Then this is much more easier compared to it, no more IIS base admin and confusing interfaces.

Now everything starts with IAppHostWritableAdminManager interface, from there you just have to swim through the elements using GetAdminSection method. Pass the section "system.applicationHost/sites"to get all the site elements on "MACHINE/WEBROOT/APPHOST".

This will list all sites. Select a site or create a one in the collection. Say you need to create an applicatin under default website, select the first element in collection and find all the Application. You can create one here using createelement method. Its all XML.


Lets make to some easier. If you are looking for deploying your application through code and you know how to do it through the InetMGR MMC console, its goood enuf!

Follow these simple steps and you are there.
1) Back-up your Web.Config
2) Back-up your IIS host config file, from \System32\inetsrv\config\applicationHost.Config
3) Play around!, Setup your application manually now. Set all the handler, mime, etc
4) Your web.config is now ready. Compare once and see what gets stored here
5) Now open ApplicationHost.config and locate your application there

You will find your application under say default website as




All you have to do is get the admin section for "sites" locate the id=1 create a child element named application. Set the property called path as "/Guru" abd other property ApplicationPool as "defaultAppPool".

Create a child called VirtualDirectory and set rest of the properties.

Anything else you need to do? Well you will figure out!! You can see the difference in the original app-host file and code!
Posted by Picasa