diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcCoreLoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcCoreLoggerExtensions.cs index 0cee994b44..36221ff1c9 100644 --- a/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcCoreLoggerExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Core/Internal/MvcCoreLoggerExtensions.cs @@ -695,7 +695,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal stringBuilder.Append($"{routeKeys[i]} = \"{routeValues[i]}\", "); } } - if (action.RouteValues["page"] != null) + if (action.RouteValues.TryGetValue("page", out var page) && page != null) { _pageExecuting(logger, stringBuilder.ToString(), action.DisplayName, null); }