March 24, 2005

Putting it together with Duct Tape and Baling Wire

My new custom 404.ASP page reads <%
If Request.QueryString <> "404;http://www.richgautier.com:80/styles/null" Then
Set FileObject = Server.CreateObject( "Scripting.FileSystemObject" )
Set LogStream = FileObject.OpenTextFile (Server.MapPath ("/statistics")& "\-----,txt" ,8, true)
LogStream.WriteLine ("404 on " & Request.QueryString)
LogStream.Close

Response.Redirect "\index.asp"
End If
%>
as shown in the box. You see, in my stylesheets I added a hack to fix an Internet Explorer CSS Display bug wherein CSS floating elements slice themselves off to match the size of its neighbors when hovering over links in the parent element (div/span). The hack involves pointing to a background image, which forces a redraw....but I didn't want an actual image to be used, so I pointed it to 'null'...which generates a request back to the server for an image that isn't there. I guess that I could create an empty image called null, but that didn't occur to me while I was fixing the 404 redirect page. Oh well, I need a way to track 404's anyway, since GoDaddy.Com doesn't give me the ability to scan my raw log files for free. So, I use ASP to track session and application stats, and visits to my web page, including referers (sp?). Obviously, in the code I am posting here, I've changed the filename I track to -----------. You'll want to make this an actual file on your server if you use it. The 8 represents APPEND mode for opening the file.

No comments: