PRB: document.lastModified Property is Unreadable with ASP
ID: Q165862
|
The information in this article applies to:
-
Active Server Pages
-
Microsoft Internet Information Server versions 4.0, 5.0
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.
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.
STATUS
Microsoft has confirmed this to be a problem in Internet Explorer versions
3.0 and 3.01.
MORE INFORMATION
Steps to Reproduce Behavior
- 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>
- Launch Internet Explorer, and enter the URL that points to this page in the following address box:
http://<server>/<vroot_name>/baddate.asp
- Observe that the date appears to be corrupted.
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/
Additional query words:
Keywords : kbASP kbJScript kbScript kbVBScript kbGrpASP kbCodeSnippet kbiis400 kbiis500
Version : winnt:4.0,5.0
Platform : winnt
Issue type : kbprb