From 0d95262bb35d003c75a48ec0193836857239715f Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Thu, 21 Nov 2024 21:33:39 +0000 Subject: [PATCH] httpContext is null --- .../Infrastructures/SharpCacheAttribute.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Infrastructure/BotSharp.Abstraction/Infrastructures/SharpCacheAttribute.cs b/src/Infrastructure/BotSharp.Abstraction/Infrastructures/SharpCacheAttribute.cs index c8b29ecd..c8f6a674 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Infrastructures/SharpCacheAttribute.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Infrastructures/SharpCacheAttribute.cs @@ -50,7 +50,9 @@ public class SharpCacheAttribute : MoAttribute } var httpContext = Services.GetRequiredService(); - 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; }