How can I create a new application pool in a Web Setup Project?

后端 未结 2 1486
忘掉有多难
忘掉有多难 2020-12-15 08:34

I need to deploy my web service. It needs to run in a separate application pool in IIS with its own credentials.

Is it possible to do this by using a Web Setup Proj

2条回答
  •  抹茶落季
    2020-12-15 08:53

    Check out this post http://forums.iis.net/t/1061734.aspx, it will give some rough idea about Microsoft.Web.Administration dll.

    I have not studied the whole concept but I figured how to create new pool and how to attach with new web site / virtual directory.

    Creating Application Pool

    Microsoft.Web.Administration.ServerManager manager = new Microsoft.Web.Administration.ServerManager();
    manager.ApplicationPools.Add("NewApplicationPool");
    manager.CommitChanges();
    

    Attaching with existing virtual directory

    Microsoft.Web.Administration.ServerManager manager = new Microsoft.Web.Administration.ServerManager();
    Site defaultSite = manager.Sites["Default Web Site"];
    
    // defaultSite.Applications will give you the list of 'this' web site reference and all
    // virtual directories inside it -- 0 index is web site itself.
    
    Microsoft.Web.Administration.Application oVDir = defaultSite.Applications["/myApp"];            
    oVDir.ApplicationPoolName = "NewApplicationPool";
    manager.CommitChanges();
    

    This way you can assign application pool to your new website using the custom actions, overriding the commit method of installer class.

    If still find yourself struggling, please let me know and I'll try to send the code.

    Regards Faiyaz faiyazkhan@hotmail.com

提交回复
热议问题