@@ -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<string, string> cache = new ConcurrentDictionary<string, string>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user