Register all the Web ADF Samples with IIS at Once
March 29, 2007You know the drill… if you’re creating an ASP.Net web application, you need to configure its folder as an application within IIS.
ArcGIS Server comes with 52 samples ADF web applications, 26 in C#, 26 in VB.Net. Stick them into folders within your web root, and you’ll have 52 error messages telling you to configure your 52 folders as IIS applications.
Here’s a rough VBS script that walks your web root, wiring up an IIS application anywhere it sees web.config file:
FixAspxRoots.vbs
Dim IISroot
Dim objFSO
Set objFSO = CreateObject(”Scripting.FileSystemObject”)
Set IISroot = GetObject(”IIS://localhost/W3SVC/1/ROOT”)
objStartFolder = IISroot.path
WScript.Echo “Scanning for web.config files below ” + objStartFolder
ExamineSubfolders objFSO.GetFolder(objStartFolder)
IISroot.SetInfo()
Sub ExamineSubFolders(Folder)
If (objFSO.FileExists(Folder.path + “\web.config”)) Then AddvirtualDir Folder.Path, Folder.name
For Each Subfolder in Folder.SubFolders
ExamineSubFolders Subfolder
Next
End Sub
Sub AddVirtualDir(folderPath, folderName)
Dim iispath
Dim VirtualDir
iisPath = replace(mid(folderPath, len(objStartFolder)+2), “\”, “/”)
Set VirtualDir = Nothing
On Error Resume Next
Set VirtualDir = GetObject(”IIS://localhost/W3SVC/1/ROOT/” & iispath)
On Error Goto 0
If Not VirtualDir Is Nothing Then
If (VirtualDir.class = “IISWebVirtualDir”) Then
’I'm assuming that this should be a webdir, not a vdir
WScript.Echo “killing vdir ” & iispath
Set IISParent = GetObject(VirtualDir.Parent)
IISParent.Delete VirtualDir.class, VirtualDir.name
IISParent.SetInfo()
WScript.Echo “Creating IIsWebDirectory ” & iispath
Set VirtualDir = IISroot.Create(”IIsWebDirectory”, iispath)
Else
WScript.Echo “updating ” & VirtualDir.class & ” ” & iispath
End If
Else
WScript.Echo “Creating IIsWebDirectory ” & iispath
Set VirtualDir = IISroot.Create(”IIsWebDirectory”, iispath)
End If
’I have no idea what half these settings mean
VirtualDir.AppIsolated = 0
VirtualDir.AppFriendlyName = folderName
VirtualDir.AccessScript = true
VirtualDir.AccessRead = true
VirtualDir.SetInfo
VirtualDir.AppCreate2 1
VirtualDir.SetInfo
End Sub