Question

I have a Visual Basic application that creates an application pool and applications. Running it on a 64-bit Windows 8 machine results in the pool and applications getting created in IIS Express 8.0 rather than IIS 8.0. I have opened applicationhost.config in \documents\IISExpress and verified that the changes are being made there. I would appreciate any insight on how to target IIS rather than IIS Express. The configuration application will normally run on a web server but needs to work on a development machine as well. Here is the code to get the IIS Version:

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

Using both localhost and machine name for the DomainName above connects it to IIS Express. Here is my function to create the application pool. The loop that sets the poolName variable is for debugging that helped determine it was using IIS Express. Again, it works but creates the pool in 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

Any assistance is appreciated.

Was it helpful?

Solution

By default Microsoft.Web.Administration is version 7.9.0.0 which is valid only for IIS Express.

Add the Microsoft.Web.Administration 7.0.0.0 and you'll be able to manage IIS server. You'll find it easily with NuGet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top