now we working for a web application installer, which need to create a web application for IIS7, does anyone know how to create a new application under Default Web Site through msi custom action?
For IIS6, we wrote the custom action use native c++ code. and in my test, I try to use native C++ again. But I met some difficult. Here is my logic steps.
1. Initial IAppHostWritableAdminManager object
2. put CommitPath as:MACHINE/WEBROOT/APPHOST
3. loop the site element under Sites section to get the Site element which id= 1
4. Get the site element child collection
5. use IAppHostElementCollection->CreateNewElement(L"application", &pAppElement) to create the new application element
6. using pAppElement->SetMetadata to add the path property for the new application.
Actually in Step 5 it has error. I always got the error to create new application, and the hresult is 0x80070585.
In my plan, in next, I need to get the pAppElement's child collection, then create new virtualDirectory element for this application element.
Does anyone know what's my problem?
Meanwhile, I thought my method is too complex, is there any more easy way to archive it??
We use a completely different approach here. In vista, the appcmd tool can be used to maintain site/virtual directory specific settings. You just have to call the commandline tool and retrieve it's output by redirecting the programs stdout to a pipe of yours
(handle parameters in startupinfo in CreateProcess() call).
We do not use msi; out installer allows the use of custom DLL's to be called. Inside it, we issue the necessary commands. If this is possible in msi you may try out this way. Good luck!
John.wang
2 Posts
How create new application/VD for IIS in msi custom action?
Jan 10, 2007 06:36 AM|LINK
Hi guys,
now we working for a web application installer, which need to create a web application for IIS7, does anyone know how to create a new application under Default Web Site through msi custom action?
For IIS6, we wrote the custom action use native c++ code. and in my test, I try to use native C++ again. But I met some difficult. Here is my logic steps.
1. Initial IAppHostWritableAdminManager object
2. put CommitPath as:MACHINE/WEBROOT/APPHOST
3. loop the site element under Sites section to get the Site element which id= 1
4. Get the site element child collection
5. use IAppHostElementCollection->CreateNewElement(L"application", &pAppElement) to create the new application element
6. using pAppElement->SetMetadata to add the path property for the new application.
Actually in Step 5 it has error. I always got the error to create new application, and the hresult is 0x80070585.
In my plan, in next, I need to get the pAppElement's child collection, then create new virtualDirectory element for this application element.
Does anyone know what's my problem?
Meanwhile, I thought my method is too complex, is there any more easy way to archive it??
Thanks in advance.Erni
6 Posts
Re: How create new application/VD for IIS in msi custom action?
Jan 20, 2007 08:54 AM|LINK
Hi, John.
We use a completely different approach here. In vista, the appcmd tool can be used to maintain site/virtual directory specific settings. You just have to call the commandline tool and retrieve it's output by redirecting the programs stdout to a pipe of yours (handle parameters in startupinfo in CreateProcess() call).
We do not use msi; out installer allows the use of custom DLL's to be called. Inside it, we issue the necessary commands. If this is possible in msi you may try out this way. Good luck!
Erni
ankitasdevel...
14 Posts
Re: How create new application/VD for IIS in msi custom action?
Feb 05, 2007 05:07 PM|LINK
Use Microsoft.Web.Administration.dll, found at IIS directory . Using managed APIs you can create virtual directories and web-application using C# code:
Microsoft.Web.Administration.ServerManager svrMgr = new ServerManager();
Microsoft.Web.Administration.Application applicationElement;
applicationElement = svrMgr.Sites["AddedViaApi"].Applications.CreateElement();
VirtualDirectory vDir = app.VirtualDirectories.CreateElement();
vDir.Path = "/";
//Virtual directory physical path
vDir.PhysicalPath = "C:\\inetpub\\VirtualDirectoryViaAPI";
//Adding virtual directory in Application
applicationElement.VirtualDirectories.Add(vdir);
// Virtual Path for Application
applicationElement.Path = "/trial";
// Application-pool for application
applicationElement.ApplicationPoolName = svrMgr.ApplicationPools["DefaultAppPool"].ToString();
// Add Application Element in site to create application
svrMgr.Sites["AddedViaApi"].Applications.Add(applicationElement);
svrMgr.CommitChanges();
ServerManager.CommitChanges()is required to flush changes to config files.ankitasdevel...
14 Posts
Re: How create new application/VD for IIS in msi custom action?
Feb 05, 2007 05:23 PM|LINK
Following is to create a new site:
Following is to create a new virtual directory:
- Ankit