Archive / Classic ASP

RSS feed for this section

Scripting.FileSystemObject Read Subfolders

Read subfolders with the Scripting.FileSystemObject: <% Dim fso Dim ObjFolder Dim ObjSubFolders Dim ObjSubFolder Set fso = CreateObject(“Scripting.FileSystemObject”) Set ObjFolder = fso.GetFolder([folder path]) Set ObjSubFolders = ObjFolder.SubFolders Response.Write(“<ul>”) For Each ObjSubFolder In ObjSubFolders Response.Write(“<li>” & ObjSubFolder.Name & ” – ” & ObjSubFolder.Path & “</li>”) Next Response.Write(“</ul>”) %>

How to get detailed ASP errors on Windows 2008 II7

To get the ASP error message and line number in code, do the following: 1. Go to Error pages 2. Under actions click Add 3. Enter status code 500.100 4. Select ‘Execute URL on this site’ 5. Enter your error page, i.e. 500.asp Now the Server.GetLastError object will contain the full error information.

How to display ASP errors on Windows 2008 II7

By default ASP errors are not displayed on a Windows 2008, II7 server. The default error message displayed simply says: Server Error 500 – Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. This is for very good reason. Detailed error message can display sensitive […]

ASP On Error Resume Next

Last night I found a page with an “On Error Resume Next” that has a script error that has been causing problems on one of my servers for months. It took a long time to narrow down the source to a single site but then it didn’t take long to find the page with the […]

Redirect to a single site

Use this ASP code to redirect your pages to a single site. Search engines may penalize you for duplicate content if they find content at yoursite.com and www.yoursite.com or multiple domains pointing at the same site. ‘—————————————–If  lcase(Request.ServerVariables(“HTTP_HOST”))=”lyonscom.com” OR lcase(Request.ServerVariables(“HTTP_HOST”))=”www.sitenumber2.com” OR lcase(Request.ServerVariables(“HTTP_HOST”))=”sitenumber2.com” Then Response.Status = “301 Moved Permanently” If lCase(Request.ServerVariables(“URL”)) = “/default.asp” Then   ‘ change home page here  If Len(Request.Querystring)=0 […]

ASP to PHP Convert Functions

This site might be useful for finding the PHP equivalents of ASP tasks: http://www.resources.fortunedesign.co.uk/jspack/asp2php.html Also, here is a chart of difference between the two languages: http://design215.com/toolbox/asp.php

“Save As” Dialog Box for Streaming File

To download files using a “Save As” dialog box try this code:         Select Case FileExt            Case “gif” ContentType = “image/gif”            Case “tif” ContentType = “image/tiff”            Case “jpg” ContentType = “image/jpeg”            Case “pdf” ContentType = “application/pdf”            Case “avi” ContentType = “video/x-msvideo”            Case “mp3” ContentType = “audio/mpeg”            Case “mpg” ContentType = “video/mpeg”            Case “wav” ContentType = “audio/wav”            Case “rar” ContentType = “application/x-rar-compressed”            Case “zip” ContentType = “application/x-zip-compressed”            Case […]

Permanent Redirect

Instead of doing a Response.Redirect to point to a page in a new location (I.e. the page has been renamed), do a permanent redirect. Using this code tells the search engines to no longer index the old page but to index the new page.    Response.Status = “301 Moved Permanently”   Response.AddHeader “Location”, “new-page-name.asp”