From ac28c642f8f3309cb1056e77585df991fac2d9cd Mon Sep 17 00:00:00 2001 From: Tommy Parnell Date: Sat, 25 Jun 2022 12:43:27 -0400 Subject: [PATCH] Revert "better etag filter" This reverts commit e8e9a1caa731e36ea53fafeff07faaac97da6755. --- src/TerribleDev.Blog.Web/Filters/ETagFilter.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/TerribleDev.Blog.Web/Filters/ETagFilter.cs b/src/TerribleDev.Blog.Web/Filters/ETagFilter.cs index 1287dbf..08e257f 100644 --- a/src/TerribleDev.Blog.Web/Filters/ETagFilter.cs +++ b/src/TerribleDev.Blog.Web/Filters/ETagFilter.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Concurrent; using System.Security.Cryptography; using System.Text; -using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; @@ -12,15 +11,12 @@ namespace TerribleDev.Blog.Web.Filters { public static string staticEtag = "\"" + MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString())).ToHexString().Substring(0,8) + "\""; public static ConcurrentDictionary cache = new ConcurrentDictionary(); - public override void OnActionExecuting(ActionExecutingContext context) + public override void OnActionExecuted(ActionExecutedContext context) { - context.HttpContext.Response.OnStarting(() => { - if(context.HttpContext.Response.StatusCode >= 200 && context.HttpContext.Response.StatusCode < 300 && context.HttpContext.Response.Headers.ETag.Count == 0) - { - context.HttpContext.Response.Headers.Add("ETag", staticEtag); - } - return Task.CompletedTask; - }); + if(context.HttpContext.Response.StatusCode >= 200 && context.HttpContext.Response.StatusCode < 300 && context.HttpContext.Response.Headers.ETag.Count == 0) + { + context.HttpContext.Response.Headers.Add("ETag", staticEtag); + } } } } \ No newline at end of file