2020-08-21 14:52:47 +01:00
|
|
|
using Microsoft.Extensions.Options;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core;
|
|
|
|
|
using Umbraco.Cms.Core.Configuration.Models;
|
2021-08-17 09:55:57 +02:00
|
|
|
using Umbraco.Cms.Core.Hosting;
|
|
|
|
|
using Umbraco.Cms.Core.Routing;
|
2020-02-24 16:18:47 +01:00
|
|
|
|
2022-05-09 09:39:46 +02:00
|
|
|
namespace Umbraco.Cms.Web.Common.AspNetCore;
|
|
|
|
|
|
|
|
|
|
public class AspNetCoreBackOfficeInfo : IBackOfficeInfo
|
2020-02-24 16:18:47 +01:00
|
|
|
{
|
2022-05-09 09:39:46 +02:00
|
|
|
private readonly IHostingEnvironment _hostingEnvironment;
|
|
|
|
|
private string? _getAbsoluteUrl;
|
2020-02-24 16:18:47 +01:00
|
|
|
|
2025-03-03 07:38:30 +01:00
|
|
|
public AspNetCoreBackOfficeInfo(IHostingEnvironment hostingEnviroment)
|
|
|
|
|
=> _hostingEnvironment = hostingEnviroment;
|
|
|
|
|
|
|
|
|
|
[Obsolete("The globalSettings parameter is not required anymore, use the other constructor instead. Scheduled for removal in Umbraco 17.")]
|
|
|
|
|
public AspNetCoreBackOfficeInfo(IOptionsMonitor<GlobalSettings> globalSettings, IHostingEnvironment hostingEnviroment)
|
|
|
|
|
: this(hostingEnviroment)
|
|
|
|
|
{ }
|
2020-02-24 16:18:47 +01:00
|
|
|
|
2022-05-09 09:39:46 +02:00
|
|
|
public string GetAbsoluteUrl
|
|
|
|
|
{
|
|
|
|
|
get
|
2021-08-17 09:55:57 +02:00
|
|
|
{
|
2022-05-09 09:39:46 +02:00
|
|
|
if (_getAbsoluteUrl is null)
|
2021-08-17 09:55:57 +02:00
|
|
|
{
|
2022-05-09 09:39:46 +02:00
|
|
|
if (_hostingEnvironment.ApplicationMainUrl is null)
|
2021-08-17 09:55:57 +02:00
|
|
|
{
|
2022-05-09 09:39:46 +02:00
|
|
|
return string.Empty;
|
2021-08-17 09:55:57 +02:00
|
|
|
}
|
2022-05-09 09:39:46 +02:00
|
|
|
|
|
|
|
|
_getAbsoluteUrl = WebPath.Combine(
|
|
|
|
|
_hostingEnvironment.ApplicationMainUrl.ToString(),
|
2025-03-03 07:38:30 +01:00
|
|
|
Core.Constants.System.DefaultUmbracoPath.TrimStart(Core.Constants.CharArrays.TildeForwardSlash));
|
2021-08-17 09:55:57 +02:00
|
|
|
}
|
2022-05-09 09:39:46 +02:00
|
|
|
|
|
|
|
|
return _getAbsoluteUrl;
|
2021-08-17 09:55:57 +02:00
|
|
|
}
|
2020-02-24 16:18:47 +01:00
|
|
|
}
|
|
|
|
|
}
|