Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 165862 - Last Review: July 3, 2008 - Revision: 6.0
PRB: document.lastModified Property Is Unreadable with ASP
This article was previously published under Q165862
We strongly recommend that all users upgrade to Microsoft Internet Information Services (IIS) version 7.0 running on Microsoft Windows Server 2008. IIS 7.0 significantly increases Web infrastructure security. For more information about IIS security-related topics, visit the following Microsoft Web site:
For more information about IIS 7.0, visit the following Microsoft Web site:
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.
The ASP 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, 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.
Microsoft has confirmed that this is a problem in Internet Explorer versions 3.0 and 3.01.
Steps to Reproduce Behavior
- Create a new ASP page named baddate.asp, and paste the following HTML code:
<HTML>
<BODY>
<SCRIPT LANGUAGE=VBSCRIPT>
document.write "Last Modified on " & document.lastModified
</SCRIPT>
</BODY>
</HTML>
- Save baddate.asp in a directory that corresponds to a Virtual Root in IIS. Make sure that the Virtual Root has been granted Execute permissions in IIS.
- Start Internet Explorer, and type the following URL, which points to this page, in the Address box:
http://<server>/<vroot_name>/baddate.asp
- Observe that the date appears to be corrupted.
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:
APPLIES TO
- Microsoft Active Server Pages 4.0
- Microsoft Internet Information Server 4.0
- Microsoft Internet Information Services 5.0
| kbcodesnippet kbprb kbscript KB165862 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
Be the first to leave feedback, to help others about this knowledge base
article.
(Optional) Name
(Optional)
Public URL Or Email
Comments
No
HTML -- Text Only Please