Previous Next

Thread: How create new application/VD for IIS in msi custom action?

Last post 02-02-2007 2:42 PM by ankitasdeveloper. 1 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (2 items)

Sort Posts:

  • 01-09-2007, 5:51 AM

    • John.wang
    • Not Ranked
    • Joined on 01-09-2007, 10:40 AM
    • Posts 2

    How create new application/VD for IIS in msi custom action?

    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.

    First I initialized IAppHostWritableAdminManager interface, then set commitpath to: MACHINE/WEBROOT/APPHOST . Then I got Default Web Site element, and use its element collection to create a new application element. but I don't know how to add property for it.

    Meanwhile, I thought my method is too complex, is there any more easy way to archive it??

    Thanks in advance.

     

  • 02-02-2007, 2:42 PM In reply to

    Re: How create new application/VD for IIS in msi custom action?

    Using managed APIs you can easilly do this, within custom installer class, here goes the code:

    Add reference: Microsoft.Web.Administration.dll, found at IIS directory %windir%\system32\inetsrv\

     ServerManager mgr = new ServerManager();
     Microsoft.Web.Administration.Application applicationElement;
     applicationElement = mgr.Sites["AddedViaApi"].Applications.CreateElement();

     VirtualDirectory vDir = app.VirtualDirectories.CreateElement();
     vDir.Path = "/";
     vDir.PhysicalPath = "E:\\inetpub\\WebsiteCustomError";

      //Adding virtual directory in Application
      applicationElement.VirtualDirectories.Add(vdir);

       applicationElement.Path = "/trial";
      
    applicationElement.Path  = "<your path>" ;
        applicationElement.ApplicationPoolName = "DefaultAppPool";
      //Adding Application Element in site to create application

      mgr.Sites["AddedViaApi"].Applications.Add(applicationElement);

      mgr.CommitChanges();

    ~ Ankit 

Page 1 of 1 (2 items)
Page view counter