When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Wednesday, August 04, 1999

Using the Summary Info Component

By Paul Harrap

It is a relatively easy and well-documented procedure to dynamically display an HTML document's last modification date in the browser. A few simple lines of Javascript cut and pasted into the BODY of your document and javascript-enabled browsers extract and display the modification date and time.

- continued -

<SCRIPT LANGUAGE="JavaScript"> <!-- document.write("Last Modified: "+document.lastmodified); //--> </SCRIPT>

This has advantages:

  • It produces the correct value!
  • It's dynamic!
  • It's client-side, so no load on the server
  • The client determines the format that document.lastmodified is displayed, so this should be appropriate to the user's taste.

It also has disadvantages:

  • It's client side, so some browsers might not cope.
  • The client determines the format that document.lastmodified is displayed, which control freak web site designers don't like!

As an ASP developer it should be a relatively easy matter to determine server side what the last modification date is, and then display and format it as I choose, entirely independently of the browser. This article shows how this can be done using the Summary Information Component, which comes as part of the IIS Resource Kit from Microsoft. You can even download the dll and example source from 4Guys!

The Summary Information Component is an astoundingly useful little piece of ActiveX. Once installed on your server you can create the object in ASP, and using it's methods and properties access the summary information of the files it is pointed at. The line below collects summary information about all the Microsoft Word (doc) files in the same directory as the ASP file.

Set SumInfoObject = Server.CreateObject("IISSample.SummaryInfos") SumInfoObject.SetFileSpec ".", "*.doc"

The SumInfoObject is a collection of documents and their properties can be accessed and displayed on screen. Some of the more interesting properties available are :

  • Title
  • Author
  • Subject
  • Application
  • Keywords
  • Comments
  • LastSaveTime
  • WordCount
  • Bytes

These properties can either be accessed separately as the code iterates through the collection or outputted in one of the component's predetermined formats.

SumInfoObject.Style=0 SumInfoObject.Write

Of particular interest in the dynamic Last Modified notification is the LastSaveTime property. In order to access this property for our page, we must first ensure that the Summary Information component is targeted at the correct page. How do we do that? We must ensure that the FileSpec refers to this page and no others, and as any one file name is unique in a folder we must ascertain the name of this file. We can then create a collection with just one document contained in it - this document.

Persuade IIS to tell you the name of this file. Perhaps not as easy as it sounds. Accessing the Server Variables collection and specifically Script_Name gives us the file name including the full virtual root. We don't need to know which folder the file is in, just it's name, hence some string manipulation is required. We identify the position of the rightmost "/" and take only what is to it's right... which should be the file name we require.

root_filename = Request.ServerVariables("SCRIPT_NAME") ' This string is of the type "/virtual/root/filename.???" only_filename = LCASE(RIGHT(root_filename, LEN(root_filename)-InStrRev(root_filename, "/"))) ' This takes only what comes after the very final "/"

Now we have our file name we can create the Summary Information Component Object and be sure that the only file in the collection is the one we are interested in.

Set SumInfoObject = Server.CreateObject("IISSample.SummaryInfos") ' Create Object SumInfoObject.SetFileSpec ".", only_filename ' Create Collection with this folder and this specific filename.

This SumInfoObject is a collection with only one entry, but be careful. You cannot access the LastSaveTime properties from the collection. You must iterate through every document in the collection, even though we all know there is only one document.

FOR EACH document IN SumInfoObject lastmod = document.LastSaveTime NEXT

The lastmod is a string of the type LongDate, Time and varies according to the web server's date and time settings. From here you can isolate the comma using the INSTR command, separate the Date and Time and format them as you choose. So, you could easily print out the last modified date with a simple:

Response.Write "Document last modified: " & lastmod

Well, that's it! Pretty nifty and easy, eh? Be sure to check out the Attachments for this article. Included is the Summary Information Component Object and some example ASP pages to show you how to use it!

Happy Programming!


  • The Summary Info DLL and Source in ZIP Format
  • The Script used in this Article in Text Format

  • ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article