I installed Vista RC1 / 5600 edition and have been experimenting with the Microsoft.Web.Administration namespace. These are examples I got working on my local machine running Vista Ultimate Edition. Hope these help. If you find a more efficient way, by all means pass them along! These are my first attempt to understand and learn the new Microsoft.Web.Administration Namespace.
'Create a new site called SteveSchofield.net
Dim objSite As New Microsoft.Web.Administration.ServerManager
objSite.Sites.Add("SteveSchofield.net", "c:\domains\steveschofield.net", 80)
objSite.Sites("SteveSchofield.net").ServerAutoStart = True
objSite.CommitChanges()
'Add an ManagedPipelineMode.Integrated application pool
Dim objAppPool As
New Microsoft.Web.Administration.ServerManager
objAppPool.ApplicationPools.Add("SteveSchofield.net")
objAppPool.ApplicationPools("SteveSchofield.net").ManagedPipelineMode = ManagedPipelineMode.Integrated
objAppPool.ApplicationPools("SteveSchofield.net").AutoStart = True
objAppPool.CommitChanges()
'Add an ManagedPipelineMode.Classic application
pool
Dim objAppPool As
New Microsoft.Web.Administration.ServerManager
objAppPool.ApplicationPools.Add("SteveSchofield.net")
objAppPool.ApplicationPools("SteveSchofield.net").ManagedPipelineMode = ManagedPipelineMode.Classic
objAppPool.ApplicationPools("SteveSchofield.net").AutoStart = True
objAppPool.CommitChanges()
'Create a Site, Application Pool (ManagedPipelineMode.Integrated)
and add new site to the new App pool that was just created.
Dim objSite As
New Microsoft.Web.Administration.ServerManager
objSite.Sites.Add("SteveSchofield.net", "c:\domains\steveschofield.net", 80)
objSite.ApplicationPools.Add("SteveSchofield.net").ManagedPipelineMode = ManagedPipelineMode.Integrated
objSite.Sites("SteveSchofield.net").Applications("/").ApplicationPoolName
= "SteveSchofield.net"
objSite.CommitChanges()
'Create a Site, Application Pool (ManagedPipelineMode.Classic) and
add new site to the new App pool that was just created.
Dim objSite As New Microsoft.Web.Administration.ServerManager
objSite.Sites.Add("SteveSchofield.net", "c:\domains\steveschofield.net", 80)
objSite.ApplicationPools.Add("SteveSchofield.net").ManagedPipelineMode = ManagedPipelineMode.Classic
objSite.Sites("SteveSchofield.net").Applications("/").ApplicationPoolName
= "SteveSchofield.net"
objSite.CommitChanges()
'List application pools using IIS7 namespace
Dim Server As New Microsoft.Web.Administration.ServerManager
Dim col
As ApplicationPoolCollection
Dim AppPoolName as string
Dim x as integer
col = Server.ApplicationPools
col = Server.Sites
For
x = 0 To col.Count - 1
SiteName = col(x).Name
Next
'List all worker processes using IIS7 namespace. (Note this is just an example,
there are other properties that can retrieve information about worker processes).
Dim Server
As
New Microsoft.Web.Administration.ServerManager
Dim col
As Microsoft.Web.Administration.WorkerProcessCollection
col = Server.WorkerProcesses
dim x as integer
For x = 0 To col.Count - 1
Response.Write(col.Item(x).ApplicationDomains(x).Id
& "<BR>")
Response.Write(col.Item(x).ApplicationDomains(x).Idle
& "<BR>")
Response.Write(col.Item(x).ApplicationDomains(x).PhysicalPath
& "<BR>")
Response.Write(col.Item(x).ApplicationDomains(x).VirtualPath
& "<BR>")
Response.Write(col.Item(x).ApplicationDomains(x).WorkerProcess.ProcessGuid
& "<BR>")
Next
'WebPages to help test if recycle actually worked.
'Test out the process
'Default.aspx to
show session variable
<html>
<body>
<% If Request.Querystring("ID") = "Show" Then %>
<% Session("Steve") = System.DateTime.Now() %>
<% End If %>
<% response.write(Session("Steve")) %>
</body>
</html>
'Recycle.aspx webpage
<html xmlns="http://www.w3.org/1999/xhtml" >
<head
runat="server">
<title>Untitled
Page</title>
</head>
<body>
<form id="form1"
runat="server">
<div>
Click Button to recycle<br /><br
/>
<asp:Button ID="Button2"
runat="server" Text="Button" /> </div>
</form>
</body>
</html>
'Recycle.aspx.vb code behind file
System.Web.UI.Page
Protected
Sub Button2_Click(ByVal sender As Object, ByVal e
As System.EventArgs)
Handles Button2.Click
Dim
RecycleSite As
New ServerManager
RecycleSite.ApplicationPools("SteveSchofield.net").Recycle()
End
Sub
End Class