diff --git a/Messerli.Session.AspNetCore/Internal/Response.cs b/Messerli.Session.AspNetCore/Internal/Response.cs index b5be5e0..cdfb0b6 100644 --- a/Messerli.Session.AspNetCore/Internal/Response.cs +++ b/Messerli.Session.AspNetCore/Internal/Response.cs @@ -44,7 +44,9 @@ public void SetHeader(string name, string value) => _httpContext.Response.Headers.Append(name, value); public string? GetFirstHeaderValue(string name) - => _httpContext.Response.Headers[name].FirstOrDefault(); + => _httpContext.Response.Headers.TryGetValue(name, out var value) + ? value.FirstOrDefault() + : null; private bool MapSecurePreferenceToBool(CookieSecurePreference securePreference) => securePreference switch