Automatically create IIS 6.0 websites

We have a web application portal that hosts several applications with its own IIS site. Therefore, every time we take a different machine to run our code, either a developer's workstation or server, we must create all the websites for each of our applications (and, of course, the list just keeps growing). Is there an API call to create an IIS website so that I can store all the necessary information in a database table and then write a winforms program that would check the table and automatically create one IIS website for each entry?

+4
source share
6 answers

If you want to do this in a WinForms / Console application, I highly recommend looking at the System.DirectoryServices namespace.

There is some good documentation here:

Using System.DirectoryServices to Configure IIS (MSDN)

For example, to create sites and virtual directories:

Creating Sites and Virtual Directories Using System.DirectoryServices (MSDN)

The System.DirectoryServices namespace is a managed ADSI API that uses IIS administration scripts.

For more information about the various metabase properties you will encounter, I recommend this link:

IIS Metadata Properties (MSDN)

If or when you upgrade to IIS7, I recommend taking a look at the Microsoft.Web.Administration and APPCMD .

+1
source

When IIS is installed on the server, several scripts are also installed. One of them is IISweb.vbs, as it allows you to create a website from the command line. It is usually located in your% Windows% \ System32 directory, and you can run it from the command line using Cscript iisweb.vbs sitename / d hostheader

If you need to set additional parameters on your website, there are several ways to do this, either use the adsutil.vbs script utility, or create your dummy website, export the settings to a file (save the configuration to a file), and then when you need to create a new website, ask your program to edit the settings and then import the configuration as a new website.

A good place to look can be found in the IIS 6.0 Administrator Guide

Obviously, for this you will need the appropriate permissions on the servers on which you are creating new websites.

+1
source

Another useful script is adsutil.vbs in C: \ Inetpub \ AdminScripts

What version of IIS are you using? For IIS 6: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/d3df4bc9-0954-459a-b5e6-7a8bc462960c.mspx?mfr=true

+1
source

You can use the SDC Task Library for this purpose. Here is a little guide .

+1
source

I searched the same thing and I found a code sample that creates a website in iis7 using C # and Microsoft.Web.Administration API. Add the link to C: \ Windows \ System32 \ InetServ \ Microsoft.Web.Administration.dll in the visual studio project and run the code.

http://bloggingabout.net/blogs/dennis/archive/2008/05/16/programmatically-creating-an-iis7-site.aspx

+1
source

You can create installers for your websites and run these curses or in batch mode. You can use the WiX link text or the standard Visual Studio installation project to create installers. Wix is ​​a more powerful but easiest way to get started is to create a Visual Studio installation project.

0
source

All Articles