public static string GetOptionalString(this RouteData routeData, string key)
{
if (routeData.Values.Any(x => x.Key == key))
{
if (routeData.Values.Where(x => x.Key == key).First().Value is string)
{
return routeData.GetRequiredString(key);
}
throw new InvalidOperationException("The value found with the specified key is not a string");
}
return "";
}