HttpResponseDecoratorExtensions Class
Definition
- Namespace
- Cuemon.AspNetCore.Http
- Assemblies
- Cuemon.AspNetCore.dll
Extension methods for the HttpResponse class hidden behind the IDecorator<T> interface.
public static class HttpResponseDecoratorExtensions
- Inheritance
-
HttpResponseDecoratorExtensions
Examples
The following example demonstrates how to add ETag and Last-Modified HTTP response headers using the HttpResponseDecoratorExtensions class accessed through the Decorator class.
// Program.cs
using System;
using System.Text;
using Cuemon;
using Cuemon.AspNetCore.Http;
using Cuemon.Data.Integrity;
using Cuemon.Security;
using Microsoft.AspNetCore.Http;
var context = new DefaultHttpContext();
var builder = new ChecksumBuilder(() => HashFactory.CreateFnv128());
builder.CombineWith(Encoding.UTF8.GetBytes("content-data"));
Decorator.Enclose(context.Response).AddOrUpdateEntityTagHeader(context.Request, builder);
var lastModified = new DateTime(2025, 6, 1, 12, 0, 0, DateTimeKind.Utc);
Decorator.Enclose(context.Response).AddOrUpdateLastModifiedHeader(context.Request, lastModified);
Console.WriteLine(context.Response.Headers.ETag.ToString());
Console.WriteLine(context.Response.Headers.LastModified.ToString());
Methods
| Name | Description |
|---|---|
| AddOrUpdateEntityTagHeader(IDecorator<HttpResponse>, HttpRequest, ChecksumBuilder, bool) | Attempts to add or update the enclosed HttpResponse of the |
| AddOrUpdateLastModifiedHeader(IDecorator<HttpResponse>, HttpRequest, DateTime) | Attempts to add or update the enclosed HttpResponse of the |
See Also
IDecorator<T>
Decorator<T>