From 63970ec07cc1683b8b3f8feed055a854e9a0e2b7 Mon Sep 17 00:00:00 2001 From: Daniel Lo Nigro Date: Sat, 14 Sep 2013 20:37:41 +1000 Subject: [PATCH] Don't crash if a null default is present Area routes using T4MVC can sometimes have nulls in the defaults dictionary, causing the RouteLoggingInfo class to crash when it tries to iterate through the defaults. --- src/AttributeRouting/Logging/RouteLoggingInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AttributeRouting/Logging/RouteLoggingInfo.cs b/src/AttributeRouting/Logging/RouteLoggingInfo.cs index deb104b..744e6e1 100644 --- a/src/AttributeRouting/Logging/RouteLoggingInfo.cs +++ b/src/AttributeRouting/Logging/RouteLoggingInfo.cs @@ -40,7 +40,7 @@ public static RouteLoggingInfo GetRouteInfo(string url, foreach (var @default in allDefaults) { - var defaultValue = @default.Value.ToString(); + var defaultValue = (@default.Value ?? string.Empty).ToString(); item.Defaults.Add(@default.Key, defaultValue); } @@ -144,4 +144,4 @@ public static RouteLoggingInfo GetRouteInfo(string url, return item; } } -} \ No newline at end of file +}