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