/// <summary> /// Gets the breadcrumb for the current location. /// </summary> /// <param name="html">A HtmlHelper that is the current HTML helper.</param> /// <param name="separator">A MvcHtmlString containing the separator to use between the breadcrumbs.</param> /// <param name="homeController">A string containing the name of the homepage controller.</param> /// <param name="indexAction">A string containing the name of the index action.</param> /// <returns>A MvcHtmlString containing the breadcrumb.</returns> public static MvcHtmlString GetBreadcrumb(this HtmlHelper html, MvcHtmlString separator, string homeController = "Home", string indexAction = "Index") { MvcHtmlString ReturnValue; if (html.GetControllerName(out string ControllerName) && html.GetActionName(out string ActionName)) { if (ControllerName != homeController) { string ModelName; ModelName = html.GetModelDisplayName(); if (ModelName == null) { ModelName = ControllerName; } ReturnValue = LinkExtensions.ActionLink(html, homeController, indexAction, homeController); ReturnValue = ReturnValue.Concat(separator); if (ActionName != indexAction) { string ActionDisplayName; ActionDisplayName = html.GetActionDisplayName(); if (ActionDisplayName == null) { ActionDisplayName = ActionName; } ReturnValue = ReturnValue.Concat(LinkExtensions.ActionLink(html, ModelName, indexAction, html.ViewContext.RouteData.Values["controller"].ToString())); ReturnValue = ReturnValue.Concat(separator); ReturnValue = ReturnValue.Concat(ActionDisplayName); } else { ReturnValue = ReturnValue.Concat(ModelName); } } else { ReturnValue = new MvcHtmlString(homeController); } }