इसके माध्यम से साझा किया गया


HttpResponseHeaderCollection.Age Property

Definition

Gets or sets the TimeSpan object that represents the value of an Age HTTP header on an HTTP response.

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

void Age(IReference<TimeSpan> value);
public System.Nullable<System.TimeSpan> Age { get; set; }
var iReference = httpResponseHeaderCollection.age;
httpResponseHeaderCollection.age = iReference;
Public Property Age As Nullable(Of TimeSpan)

Property Value

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

Remarks

The Age property represents the value of he Age header on an HTTP response. The Age header is the age of the entity in the cache.

When programming with .NET, this structure is hidden and developers should use the System.TimeSpan structure. The value can be null, because it's typed as TimeSpan? (a nullable TimeSpan).

In JavaScript, this structure is accessed as a value, not as an object. For example, use var a = 10000, not var a = { duration: 10000 }.

Note

In JavaScript, this structure is treated as the number of millisecond intervals, not the number of 100-nanosecond intervals. Therefore, Windows.Foundation.TimeSpan values can lose precision when being ported between languages.

For more detailed information, see the Windows.Foundation.TimeSpan interface.

The following sample code shows a method to set the Age header on an HttpResponseMessage object using the Age property on the HttpResponseHeaderCollection object.

public void DemonstrateHeaderResponseAge() {
    var response = new HttpResponseMessage();

    // Set the header with a strong type.
    DateTimeOffset value = DateTimeOffset.UtcNow;
    response.Headers.Age = new TimeSpan(1, 35, 55); // 1 hour, 35 minutes, 55 seconds.

    // Get the strong type out
    System.Diagnostics.Debug.WriteLine("Age value in minutes: {0}", response.Headers.Age.Value.TotalMinutes);

    // The ToString() is useful for diagnostics, too.
    System.Diagnostics.Debug.WriteLine("The Age ToString() results: {0}", response.Headers.Age.ToString());
}

Applies to

See also