diff --git a/src/Umbraco.Web.Common/Extensions/UrlHelperExtensions.cs b/src/Umbraco.Web.Common/Extensions/UrlHelperExtensions.cs index 6eacc2ef24..972dc67e19 100644 --- a/src/Umbraco.Web.Common/Extensions/UrlHelperExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/UrlHelperExtensions.cs @@ -22,21 +22,27 @@ namespace Umbraco.Extensions; public static class UrlHelperExtensions { + /// + /// Gets the Umbraco backoffice URL (if Umbraco is installed). + /// + /// The URL helper. + /// + /// The Umbraco backoffice URL. + /// + public static string? GetUmbracoBackOfficeUrl(this IUrlHelper urlHelper) + => urlHelper.Action("Default", "BackOffice", new { area = Constants.Web.Mvc.BackOfficeArea }); + /// /// Return the back office url if the back office is installed /// /// /// + /// + /// This method contained a bug that would result in always returning "/". + /// + [Obsolete("Use the GetUmbracoBackOfficeUrl extension method instead. This method will be removed in Umbraco 13.")] public static string? GetBackOfficeUrl(this IUrlHelper url) - { - var backOfficeControllerType = Type.GetType("Umbraco.Web.BackOffice.Controllers"); - if (backOfficeControllerType == null) - { - return "/"; // this would indicate that the installer is installed without the back office - } - - return url.Action("Default", ControllerExtensions.GetControllerName(backOfficeControllerType), new { area = Constants.Web.Mvc.BackOfficeApiArea }); - } + => "/"; /// /// Return the Url for a Web Api service