Click here to Skip to main content
15,894,266 members
Articles / Web Development / IIS

IIsManager

Rate me:
Please Sign up or sign in to vote.
4.56/5 (9 votes)
20 Aug 2008Ms-PL 37.5K   211   26  
Manage IIS 6 in .NET
Imports IIsManager

Module modTest

    Sub Main()

        Dim IIsSvc As IIsService = Nothing

        Try

            IIsSvc = New IIsService

            ' Creating a testsite, setting ASP.NET Version, setting directory Access Permissions.
            Using testsite = IIsSvc.AddSite("TestSite", "c:\inetpub\testsite", "test.site.nl")

                testsite.AccessPermissions = AccessPermissionFlags.Read + AccessPermissionFlags.Script

                testsite.ASPNETVersion = ASPNETVersions.v2_0_50727

                Using images = testsite.AddDirectory("images")
                    images.AccessPermissions = AccessPermissionFlags.Read + AccessPermissionFlags.Write
                End Using

                Console.Write("TestSite added.")
                Console.ReadLine()

                IIsSvc.RemoveSite(testsite.Id)
                Console.WriteLine("TestSite removed.")

            End Using

            ' Selecting an existing site, creating an application in a virual directory.
            Using template = (From s In IIsSvc.Sites Where s.Description = "TemplateSite" Select s).First

                Using vdnonapp = (From d In template.VirtualDirectories Where d.Name = "vdnonapp" Select d).First

                    vdnonapp.CreateApplication("bla")

                    Console.Write("Application created.")
                    Console.ReadLine()

                    vdnonapp.DeleteApplication()
                    Console.WriteLine("Application deleted.")

                End Using

            End Using


        Catch ex As Exception

            Console.WriteLine(ex.Message & vbNewLine & vbNewLine & If(ex.InnerException Is Nothing, ex.StackTrace, ex.InnerException.Message & vbNewLine & vbNewLine & ex.InnerException.StackTrace))
            Console.ReadLine()

        Finally

            If Not IIsSvc Is Nothing Then IIsSvc.Dispose()

        End Try

    End Sub

End Module

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Software Developer (Senior)
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions