PRB: document.lastModified Property is Unreadable with ASP

Last reviewed: December 11, 1997
Article ID: Q165862
The information in this article applies to:
  • Microsoft Active Server Pages, version 1.0
  • Microsoft Internet Explorer (Programming), version 3.01

SYMPTOMS

The lastModified property exposed by the Internet Explorer (IE) HTML scripting object model indicates the date and time at which the sender believes the resource was last modified. When this property is referenced in a page generated by the Active Server Page framework, an unreadable value is displayed by the client browser.

CAUSE

The Active Server Page framework does not include the Last-Modified response header in its response to the client.

RESOLUTION

According to RFC 1945, Hypertext Transfer Protocol 1.0 -- HTTP/1.0, Last-Modified is an entity header field, and entity header fields are optional. Internet Explorer 3.0 does not handle the absence of this header gracefully.

STATUS

Microsoft has confirmed this to be a problem in Internet Explorer versions 3.0 and 3.01.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a file containing the following HTML code. Save it as baddate.asp into a directory that corresponds to a Virtual Root in IIS. Make sure that the Virtual Root has been granted Execute permissions in IIS:

          <HTML>
          <BODY>
          <SCRIPT LANGUAGE=VBSCRIPT>
          document.write "Last Modified on " & document.lastModified
          </SCRIPT>
          </BODY>
          </HTML>
    

  2. Launch Internet Explorer, and enter the URL that points to this page in the address box as shown below:

    http://<server>/<vroot_name>/baddate.asp

  3. Observe that the date appears to be corrupted.

RESOLUTION

Active Server Pages provides the Response Intrinsic object. Use the Response.AddHeader method to add the Last-Modified header to the HTTP response.

According to the RFC, the user agent, IE, expects times to be expressed in Greenwich Mean Time (GMT). While VBSCRIPT does provide many date and time manipulation functions, it does not provide a function to return GMT or a function to return the current time zone offset from which GMT could be derived. The following example uses JSCRIPT on the server to append the Last-Modified response header to those provided by IIS and the Active Server Page Framework. Replace the contents of the page above with the following text:

      <%@ LANGUAGE=JSCRIPT %>

      <%
         // JSCRIPT automatically formats the string as specified
         // in RFC 1945, HTTP/1.0
         // e.g. Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT
         theCurrentTime = new Date()

         // convert the date to GMT
         theUTCLastModifiedTime = theCurrentTime.toGMTString()

         // Inject the header into the HTTP response
         Response.AddHeader("Last-modified", theUTCLastModifiedTime)
      %>

      <HTML>
      <BODY>
      <SCRIPT LANGUAGE=VBSCRIPT>
      document.write "Last Modified on " & document.lastModified
      </SCRIPT>
      </BODY>
      </HTML>

Save the ASP file on the server, and refresh the page in the client browser. The last modified date should now be displayed correctly.

REFERENCES

RFC 1945. Hypertext Transfer Protocol 1.0 -- HTTP/1.0.

On-line Active Server Pages documentation.

For the latest Knowledge Base articles and other support information on Visual InterDev and Active Server Pages, see the following page on the Microsoft Technical Support site:

   http://support.microsoft.com/support/vinterdev/

Keywords          : kbprb
Version           : 1.0 3.01
Platform          : NT WINDOWS
Issue type        : kbprb


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 11, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.