我有一个创建应用程序池和应用程序的 Visual Basic 应用程序。在 64 位 Windows 8 机器上运行它会导致在 IIS Express 8.0 而不是 IIS 8.0 中创建池和应用程序。我已经在 \documents\IISExpress 中打开了 applicationhost.config 并验证了那里正在进行更改。我将不胜感激有关如何针对 IIS 而不是 IIS Express 的任何见解。配置应用程序通常会在 Web 服务器上运行,但也需要在开发机器上运行。以下是获取 IIS 版本的代码:
Dim rootId As DirectoryEntry = GetDirectoryEntry(String.Format("IIS://{0}/W3SVC/Info", DomainName))
If rootId IsNot Nothing Then
Try
If rootId.Properties.Contains("MajorIIsVersionNumber") = True Then
Dim iisVal As String = rootId.Properties("MajorIIsVersionNumber").Value.ToString
使用 localhost 和机器名作为上面的 DomainName 将其连接到 IIS Express。这是我创建应用程序池的功能。设置 poolName 变量的循环用于帮助确定它使用 IIS Express 的调试。同样,它可以工作,但会在 IIS Express 中创建池。
Private Function GetOrCreateAppPool(ByRef mgr As ServerManager, ByVal domainPath As String, ByVal appPoolName As String, ByVal addAppPool As Boolean) As ApplicationPool
' First see if app pool exists
Dim appPoolId As ApplicationPool = Nothing
Dim poolId As ApplicationPool
Dim poolName As String
For Each poolId In mgr.ApplicationPools
poolName = poolId.Name
Next
appPoolId = mgr.ApplicationPools(appPoolName)
If appPoolId Is Nothing Then
appPoolId = mgr.ApplicationPools.Add(appPoolName)
If appPoolId IsNot Nothing Then
With appPoolId
.AutoStart = True
.ManagedPipelineMode = ManagedPipelineMode.Integrated
.ManagedRuntimeVersion = "v4.0"
.ProcessModel.IdentityType = ProcessModelIdentityType.NetworkService
.ProcessModel.IdleTimeout = TimeSpan.FromMinutes(240)
.Recycling.PeriodicRestart.Time = TimeSpan.FromMinutes(0)
.Recycling.PeriodicRestart.Schedule.Add(TimeSpan.Parse("03:00:00"))
End With
mgr.CommitChanges()
End If
End If
Return appPoolId
End Function
任何帮助表示赞赏。