diff --git a/src/Umbraco.Web.Common/Extensions/LinkGeneratorExtensions.cs b/src/Umbraco.Web.Common/Extensions/LinkGeneratorExtensions.cs
index ce6e8c7816..70f8d1c2fe 100644
--- a/src/Umbraco.Web.Common/Extensions/LinkGeneratorExtensions.cs
+++ b/src/Umbraco.Web.Common/Extensions/LinkGeneratorExtensions.cs
@@ -13,32 +13,25 @@ namespace Umbraco.Extensions;
public static class LinkGeneratorExtensions
{
///
- /// Return the back office url if the back office is installed
+ /// Gets the backoffice URL (if the back office is installed).
///
- public static string? GetBackOfficeUrl(this LinkGenerator linkGenerator, IHostingEnvironment hostingEnvironment)
- {
- Type? backOfficeControllerType;
- try
- {
- backOfficeControllerType = Assembly.Load("Umbraco.Web.BackOffice")
- .GetType("Umbraco.Web.BackOffice.Controllers.BackOfficeController");
- if (backOfficeControllerType == null)
- {
- return "/"; // this would indicate that the installer is installed without the back office
- }
- }
- catch
- {
- return
- hostingEnvironment
- .ApplicationVirtualPath; // this would indicate that the installer is installed without the back office
- }
+ /// The link generator.
+ ///
+ /// The backoffice URL.
+ ///
+ public static string? GetBackOfficeUrl(this LinkGenerator linkGenerator)
+ => linkGenerator.GetPathByAction("Default", "BackOffice", new { area = Constants.Web.Mvc.BackOfficeArea });
- return linkGenerator.GetPathByAction(
- "Default",
- ControllerExtensions.GetControllerName(backOfficeControllerType),
- new { area = Constants.Web.Mvc.BackOfficeApiArea });
- }
+ ///
+ /// Gets the backoffice URL (if the back office is installed) or application virtual path (in most cases just "/").
+ ///
+ /// The link generator.
+ /// The hosting environment.
+ ///
+ /// The backoffice URL.
+ ///
+ public static string GetBackOfficeUrl(this LinkGenerator linkGenerator, IHostingEnvironment hostingEnvironment)
+ => GetBackOfficeUrl(linkGenerator) ?? hostingEnvironment.ApplicationVirtualPath;
///
/// Return the Url for a Web Api service