HttpLastModifiedHeaderOptions Class
Definition
- Namespace
- Cuemon.AspNetCore.Mvc.Filters.Cacheable
- Assemblies
- Cuemon.AspNetCore.Mvc.dll
Specifies options that is related to the HttpLastModifiedHeaderFilter.
public class HttpLastModifiedHeaderOptions : IParameterObject
- Inheritance
-
objectHttpLastModifiedHeaderOptions
- Implements
Examples
The following example applies the default to a timestamped response model.
using System;
using Cuemon.AspNetCore.Mvc.Filters.Cacheable;
using Cuemon.Data.Integrity;
using Microsoft.AspNetCore.Http;
using Microsoft.Net.Http.Headers;
namespace MyApp.Examples;
public static class HttpLastModifiedHeaderOptionsExample
{
public static void Demonstrate()
{
var options = new HttpLastModifiedHeaderOptions();
var context = new DefaultHttpContext();
context.Request.Method = HttpMethods.Get;
var timestamp = new SampleEntityDataTimestamp(
DateTime.Parse("2024-01-01T00:00:00Z"),
DateTime.Parse("2024-01-02T00:00:00Z"));
options.LastModifiedProvider(timestamp, context);
Console.WriteLine(options.HasLastModifiedProvider);
Console.WriteLine(context.Response.Headers[HeaderNames.LastModified].ToString());
}
private sealed class SampleEntityDataTimestamp : IEntityDataTimestamp
{
public SampleEntityDataTimestamp(DateTime created, DateTime? modified)
{
Created = created;
Modified = modified;
}
public DateTime Created { get; }
public DateTime? Modified { get; }
}
}
Constructors
| Name | Description |
|---|---|
| HttpLastModifiedHeaderOptions() | Initializes a new instance of the HttpLastModifiedHeaderOptions class. |
Properties
| Name | Description |
|---|---|
| HasLastModifiedProvider | Gets a value indicating whether this instance has an LastModifiedProvider. |
| LastModifiedProvider | Gets or sets the delegate that is invoked when a result of a ResultExecutingContext is an ObjectResult and the value is an IEntityDataTimestamp implementation. |