Archive for March, 2007

Register all the Web ADF Samples with IIS at Once

March 29, 2007

You 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

Search compiled code with Reflector

March 28, 2007

I regularly use Lutz Roeder’s .NET Reflector for gaining insight into mysterious new codebases.  I was always a little disappointed in its search functionality though — it can only search through Types, Members, and Constants.  Today I discovered a little tool that will make my life 100% easier.  A Code Search Add-In for Reflector:

 http://www.codeplex.com/reflectoraddins

Overcoming Slow AJAX Form Serialization

March 28, 2007

Those of you familiar with Prototype know that Form.Serialize is one bad-ass capability.  The depressing part comes when you realize just how long serializing complex forms can take.

So how can you quickly serialize large forms for postback via AJAX?  Simple, you don’t.  Here’s how:

1) Post your entire page using a standard form submittal with an additional unique ID for the request.

2) Server-side, store the GET/POST data but don’t process it, return an HTTP 204 — “No Content”

3) Finally use AJAX to retrieve the GET/POST data … or retrieve the results from the form posting

Note that I haven’t actually tried this, but it strikes me as clean enough.  Sure its a nasty hack, but it beats serializing forms in JS, and if you wrapped it in a pretty OO JS class, people just might call you genius.

PsService Batch Files for ArcIMS Administration

March 27, 2007

Dave Bouwman had a post on using the “NET” command for service administration.  Hats off to Dave, but PsService fits much better into my workflow.

Check out http://www.microsoft.com/technet/sysinternals/ProcessesAndThreads/PsService.mspx

Now check out the code below, half stolen, half rewritten:

@echo off

echo **************************************
echo Stopping IMS Services
echo **************************************

psservice \\10.147.156.69 STOP “ArcIMS Tasker 9.2.0″

psservice \\10.147.156.69 STOP “ArcIMS Monitor 9.2.0″

psservice \\10.147.156.69 STOP “ArcIMS Application Server 9.2.0″

pause

cls
echo ***************************
echo Restarting IMS Services
echo ***************************
psservice \\10.147.156.69 start “ArcIMS Application Server 9.2.0″

psservice \\10.147.156.69 start “ArcIMS Monitor 9.2.0″

psservice \\10.147.156.69 start “ArcIMS Tasker 9.2.0″

pause

Hello world!

March 27, 2007

Today I start that short, violent ascent towards fame.

James Fee, here I come.