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;
|
|
|
|
|
using static Umbraco.Cms.Core.Constants;
|
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 IOptionsMonitor<GlobalSettings> _globalSettings;
|
|
|
|
|
private readonly IHostingEnvironment _hostingEnvironment;
|
|
|
|
|
private string? _getAbsoluteUrl;
|
2020-02-24 16:18:47 +01:00
|
|
|
|
2022-05-09 09:39:46 +02:00
|
|
|
public AspNetCoreBackOfficeInfo(
|
|
|
|
|
IOptionsMonitor<GlobalSettings> globalSettings,
|
|
|
|
|
IHostingEnvironment hostingEnviroment)
|
|
|
|
|
{
|
|
|
|
|
_globalSettings = globalSettings;
|
|
|
|
|
_hostingEnvironment = 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(),
|
2024-11-07 12:20:22 +01:00
|
|
|
Core.Constants.System.DefaultUmbracoPath.TrimStart(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
|
|
|
}
|
|
|
|
|
}
|