diff --git a/src/OrchardCore.Themes/TheAdmin/Views/NavigationItemLink-admin.cshtml b/src/OrchardCore.Themes/TheAdmin/Views/NavigationItemLink-admin.cshtml index a7e8ae2bb81..c93a83c959c 100644 --- a/src/OrchardCore.Themes/TheAdmin/Views/NavigationItemLink-admin.cshtml +++ b/src/OrchardCore.Themes/TheAdmin/Views/NavigationItemLink-admin.cshtml @@ -7,23 +7,26 @@ TagBuilder tag = Tag(Model, "a"); tag.Attributes["id"] = null; - tag.Attributes["href"] = Model.Href; - if (Model.Href.ToString() == "#") + if (Model.Href == null || Model.Href.ToString() == "#") { tag.Attributes["href"] = "#m" + Model.GetHashCode().ToString(); + } + else + { + tag.Attributes["href"] = Model.Href; } var prefix = "icon-class-"; - // Extract classes that are not icons from Model.Classes + // Extract classes that are not icons from Model.Classes. var notIconClasses = ((IEnumerable)Model.Classes) - .ToList() - .Where(c => !c.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)); + .Where(c => !c.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) + .ToArray(); - if (notIconClasses.Count() > 0) + if (notIconClasses.Length > 0) { - tag.Attributes["class"] = string.Join(" ", notIconClasses); + tag.Attributes["class"] = string.Join(' ', notIconClasses); } tag.AddCssClass("item-label d-flex");