【问题标题】:Changing the application pool through a Web Deployment Project通过 Web 部署项目更改应用程序池
【发布时间】:2008-10-03 14:45:45
【问题描述】:

有没有办法配置 Visual Studio 2005 Web 部署项目以将应用程序安装到指定的应用程序池而不是给定网站的默认应用程序池中?

【问题讨论】:

    标签: c# deployment windows-installer asp.net-2.0


    【解决方案1】:

    这里有一篇描述自定义操作的好文章: ScottGu's Blog

    'Ryan' 在 cmets 中回答了你的问题,不幸的是它在 VB 中,但应该不难翻译:

    Private Sub assignApplicationPool(ByVal WebSite As String, ByVal Vdir As String, ByVal appPool As String)
       Try
         Dim IISVdir As New DirectoryEntry(String.Format("IIS://{0}/W3SVC/1/Root/{1}", WebSite, Vdir))
         IISVdir.Properties.Item("AppPoolId").Item(0) = appPool
         IISVdir.CommitChanges()
       Catch ex As Exception
         Throw ex
       End Try
     End Sub
    
     Private strServer As String = "localhost"
     Private strRootSubPath As String = "/W3SVC/1/Root"
     Private strSchema As String = "IIsWebVirtualDir"
     Public Overrides Sub Install(ByVal stateSaver As IDictionary)
       MyBase.Install(stateSaver)
       Try
         Dim webAppName As String = MyBase.Context.Parameters.Item("TARGETVDIR").ToString
         Dim vdirName As String = MyBase.Context.Parameters.Item("COMMONVDIR").ToString
         Me.assignApplicationPool(Me.strServer, MyBase.Context.Parameters.Item("TARGETVDIR").ToString, MyBase.Context.Parameters.Item("APPPOOL").ToString)
       Catch ex As Exception
         Throw ex
       End Try
     End Sub
    

    ...APPPOOL 在自定义操作中作为参数提供。

    【讨论】:

    • 我正在为我的设置中的 2 个 Web 应用程序执行此操作 - 它适用于作为第二个 Web 应用程序的“Web 自定义文件夹”,但适用于您获得的“Web 应用程序文件夹”默认情况下,它将在自定义操作期间设置应用程序池 - 但完成后将其设置回默认应用程序。
    【解决方案2】:

    您可以在部署期间使用 CustomAction 来修改 IIS,这里有一篇文章如何做到这一点: Modifying Internet Information Services During Deployment with Custom Actions

    文中的例子是在VB.Net中,并没有明确说明如何更改应用程序池,但应该很容易理解。

    【讨论】:

      猜你喜欢
      • 2014-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-23
      • 2016-05-20
      相关资源
      最近更新 更多