From 6bd523d5a0e1c8725cb27080718070c2633c477c Mon Sep 17 00:00:00 2001 From: Szabolcs Deme Date: Tue, 23 May 2023 18:16:57 +0200 Subject: [PATCH] Adding null check to avoid rare http 500 errors --- Lombiq.Privacy/Startup.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lombiq.Privacy/Startup.cs b/Lombiq.Privacy/Startup.cs index 48a524d..c36e2a6 100644 --- a/Lombiq.Privacy/Startup.cs +++ b/Lombiq.Privacy/Startup.cs @@ -50,6 +50,12 @@ public override void ConfigureServices(IServiceCollection services) private static Task IsConsentNeededAsync(HttpContext httpContext) { var consentService = httpContext.RequestServices.GetService(); + + if (consentService == null) + { + return Task.FromResult(true); + } + return consentService.IsConsentNeededAsync(httpContext); } }