Export (0) Print
Expand All

HttpCachePolicy.SetExpires Method

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

[Visual Basic]
Public Sub SetExpires( _
   ByVal date As DateTime _
)
[C#]
public void SetExpires(
 DateTime date
);
[C++]
public: void SetExpires(
 DateTime date
);
[JScript]
public function SetExpires(
   date : DateTime
);

Parameters

date
The absolute DateTime value to set the Expires header to.

Remarks

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

Example

The following example sets the expiration time to 6:00 P.M. local time on the current expiration day.

[Visual Basic] 
Response.Cache.SetExpires(DateTime.Parse("6:00:00PM"))
    

[C#] 
Response.Cache.SetExpires(DateTime.Parse("6:00:00PM"));
    

[C++] 
Response->Cache->SetExpires(DateTime::Parse(S"6:00:00PM"));
    

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

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HttpCachePolicy Class | HttpCachePolicy Members | System.Web Namespace

Show:
© 2015 Microsoft