SetLastModified Method

HttpCachePolicy.SetLastModified Method

Sets the Last-Modified HTTP header to the DateTime value supplied.

Namespace: System.Web
Assembly: System.Web (in system.web.dll)

public void SetLastModified (
	DateTime date
public void SetLastModified (
	DateTime date
public function SetLastModified (
	date : DateTime



The new DateTime value for the Last-Modified header.

Exception typeCondition


date is later than the current DateTime.

The Last-Modified HTTP header time stamps the document with the DateTime value indicating when the document was last modified.

This method will fail if the caching restrictiveness hierarchy is violated.

The following code example demonstrates how to set the Last-Modified header to a new date.

Response.Cache.SetLastModified(DateTime.Parse("1/1/2001 00:00:01AM"));

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

© 2016 Microsoft