From f35deb71f935832276f36d61d597fb2c37357f85 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 7 May 2018 10:45:54 -0700 Subject: [PATCH] Prevent KeyNotFound when logging --- .../Internal/MvcCoreLoggerExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); }