我有一个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
使用上面DomainName的localhost和machine name将其连接到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
感谢任何帮助。
答案 0 :(得分:0)
默认情况下,Microsoft.Web.Administration版本为7.9.0.0,仅对IIS Express有效。
添加Microsoft.Web.Administration 7.0.0.0,您将能够管理IIS服务器。您可以通过NuGet轻松找到它。