PRB: document.lastModified Property Is Unreadable with ASP (165862)
The information in this article applies to:
- Microsoft Active Server Pages
- Microsoft Internet Information Server 4.0
- Microsoft Internet Information Server 5.0
This article was previously published under Q165862 We strongly recommend that all users upgrade to Microsoft Internet Information Services (IIS) version 6.0 running on Microsoft Windows Server 2003. IIS 6.0 significantly increases Web infrastructure security. For more information about IIS security-related topics, visit the following Microsoft Web site: SYMPTOMS
The lastModified property that the Internet Explorer HTML
scripting object model exposes indicates the date and time at which the sender believes the resource was last modified. When this property is referenced in a page that the Active Server Page (ASP) framework generates, the client browser displays an unreadable value.
CAUSE
The ASP 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.
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, Internet Explorer, expects times to be expressed in Greenwich Mean Time (GMT). Although Microsoft Visual Basic Scripting Edition (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 code:
<%@ 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.
STATUSMicrosoft has confirmed that this is a problem in Internet Explorer versions 3.0 and 3.01. 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:
Modification Type: | Major | Last Reviewed: | 5/2/2006 |
---|
Keywords: | kbCodeSnippet kbprb kbScript KB165862 |
---|
|