Files
Umbraco-CMS/src/Umbraco.Web.Common/AspNetCore/AspNetCoreBackOfficeInfo.cs

42 lines
1.4 KiB
C#
Raw Normal View History

using Microsoft.Extensions.Options;
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
namespace Umbraco.Cms.Web.Common.AspNetCore;
public class AspNetCoreBackOfficeInfo : IBackOfficeInfo
2020-02-24 16:18:47 +01:00
{
private readonly IHostingEnvironment _hostingEnvironment;
private string? _getAbsoluteUrl;
2020-02-24 16:18:47 +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
public string GetAbsoluteUrl
{
get
2021-08-17 09:55:57 +02:00
{
if (_getAbsoluteUrl is null)
2021-08-17 09:55:57 +02:00
{
if (_hostingEnvironment.ApplicationMainUrl is null)
2021-08-17 09:55:57 +02:00
{
return string.Empty;
2021-08-17 09:55:57 +02:00
}
_getAbsoluteUrl = WebPath.Combine(
_hostingEnvironment.ApplicationMainUrl.ToString(),
Core.Constants.System.DefaultUmbracoPath.TrimStart(Core.Constants.CharArrays.TildeForwardSlash));
2021-08-17 09:55:57 +02:00
}
return _getAbsoluteUrl;
2021-08-17 09:55:57 +02:00
}
2020-02-24 16:18:47 +01:00
}
}