httpContext is null

This commit is contained in:
Haiping Chen 2024-11-21 21:33:39 +00:00
parent 6a5b74568b
commit 0d95262bb3

View file

@ -50,7 +50,9 @@ public class SharpCacheAttribute : MoAttribute
}
var httpContext = Services.GetRequiredService<IHttpContextAccessor>();
if (httpContext.HttpContext.Response.Headers["Cache-Control"].ToString().Contains("no-store"))
if (httpContext != null &&
httpContext.HttpContext != null &&
httpContext.HttpContext.Response.Headers["Cache-Control"].ToString().Contains("no-store"))
{
return;
}