Export (0) Print
Expand All

HttpCachePolicy.SetExpires Method

Sets the Expires HTTP header to an absolute date and time.

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

public void SetExpires (
	DateTime date
)
public void SetExpires (
	DateTime date
)
public function SetExpires (
	date : DateTime
)
Not applicable.

Parameters

date

The absolute DateTime value to set the Expires header to.

This method will fail if the expiration date violates the principle of restrictiveness.

TopicLocation
How to: Cache Versions of a Page Using ParametersBuilding ASP .NET Web Applications
How to: Cache Versions of a Page Using ParametersBuilding ASP .NET Web Applications

The following code example demonstrates how to set the expiration time to 6:00 P.M. local time on the current expiration day.

Response.Cache.SetExpires(DateTime.Parse("6:00:00PM"));
    

get_Response().get_Cache().SetExpires(DateTime.Parse("6:00:00PM"));

Response.Cache.SetExpires(DateTime.Parse("6:00:00PM"))
    

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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft