PRB: document.lastModified Property is Unreadable with ASPID: Q165862
|
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.
The Active Server Page framework does not include the Last-Modified response header in its response to the client.
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, 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 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.
Microsoft has confirmed this to be a problem in Internet Explorer versions 3.0 and 3.01. This behavior is by design.
<HTML>
<BODY>
<SCRIPT LANGUAGE=VBSCRIPT>
document.write "Last Modified on " & document.lastModified
</SCRIPT>
</BODY>
</HTML>
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/
Additional query words:
Keywords : kbsample kbASP kbIE300 kbIE301 kbJScript kbScript kbVBScript kbGrpASP
Version : WINDOWS:3.01; winnt:
Platform : WINDOWS winnt
Issue type : kbprb
Last Reviewed: May 27, 1999