Share via


HttpContentHeaderCollection.Expires Property

Definition

Gets or sets the DateTime object that represents the value of an HTTP Expires header on the HTTP content.

public:
 property IReference<DateTime> ^ Expires { IReference<DateTime> ^ get(); void set(IReference<DateTime> ^ value); };
IReference<DateTime> Expires();

void Expires(IReference<DateTime> value);
public System.Nullable<System.DateTimeOffset> Expires { get; set; }
var iReference = httpContentHeaderCollection.expires;
httpContentHeaderCollection.expires = iReference;
Public Property Expires As Nullable(Of DateTimeOffset)

Property Value

The object that represents the value of an HTTP Expires header on the HTTP content. A null value means that the header is absent.

Remarks

The Expires property represents the value of the Expires header on HTTP content. The Expires header is the date and time after which the HTTP content is considered outdated.

Javascript and .NET languages do not use the DateTime object directly. In Javascript a DateTime is projected as a object, and in .NET it is projected as a System.DateTimeOffset. Each language transparently handles the conversion to the granularity and date ranges for the respective language.

In C++, a value has the same granularity as a and supports the date ranges required by Javascript and .NET.

For more detailed information, see the Windows.Foundation.DateTime structure.

The following sample code shows a method to get or set the Expires header value on HTTP content using the Expires property on the HttpContentHeaderCollection object.

// Expires header
// nullable DateTimeOffset
//
void DemoExpires(IHttpContent content) {
    var h = content.Headers;
    h.Expires = DateTimeOffset.Now;

    var header = h.Expires;
    uiLog.Text += "\nEXPIRES HEADER\n";
    uiLog.Text += String.Format ("Expires: {0}\n", header.ToString());
}

Applies to

See also