Getting the IISVersion through HostingEnvironment, rather than directly calling HttpRuntime, fixing base ctor signature
This commit is contained in:
+13
-9
@@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Web.HealthCheck.Checks.Config
|
||||
@@ -12,11 +13,14 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
|
||||
Group = "Configuration")]
|
||||
public class TrySkipIisCustomErrorsCheck : AbstractConfigCheck
|
||||
{
|
||||
private readonly Version _serverVersion = HttpRuntime.IISVersion;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
|
||||
public TrySkipIisCustomErrorsCheck(ILocalizedTextService textService, IIOHelper ioHelper)
|
||||
: base(textService, ioHelper)
|
||||
{ }
|
||||
public TrySkipIisCustomErrorsCheck(ILocalizedTextService textService, IIOHelper ioHelper, ILogger logger,
|
||||
IHostingEnvironment hostingEnvironment)
|
||||
: base(textService, ioHelper, logger)
|
||||
{
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
}
|
||||
|
||||
public override string FilePath => "~/Config/umbracoSettings.config";
|
||||
|
||||
@@ -29,7 +33,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
|
||||
get
|
||||
{
|
||||
// beware! 7.5 and 7.5.0 are not the same thing!
|
||||
var recommendedValue = _serverVersion >= new Version("7.5")
|
||||
var recommendedValue = _hostingEnvironment.IISVersion >= new Version("7.5")
|
||||
? bool.TrueString.ToLower()
|
||||
: bool.FalseString.ToLower();
|
||||
return new List<AcceptableConfiguration> { new AcceptableConfiguration { IsRecommended = true, Value = recommendedValue } };
|
||||
@@ -41,7 +45,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
|
||||
get
|
||||
{
|
||||
return TextService.Localize("healthcheck/trySkipIisCustomErrorsCheckSuccessMessage",
|
||||
new[] { Values.First(v => v.IsRecommended).Value, _serverVersion.ToString() });
|
||||
new[] { Values.First(v => v.IsRecommended).Value, _hostingEnvironment.IISVersion.ToString() });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +54,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
|
||||
get
|
||||
{
|
||||
return TextService.Localize("healthcheck/trySkipIisCustomErrorsCheckErrorMessage",
|
||||
new[] { CurrentValue, Values.First(v => v.IsRecommended).Value, _serverVersion.ToString() });
|
||||
new[] { CurrentValue, Values.First(v => v.IsRecommended).Value, _hostingEnvironment.IISVersion.ToString() });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +63,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
|
||||
get
|
||||
{
|
||||
return TextService.Localize("healthcheck/trySkipIisCustomErrorsCheckRectifySuccessMessage",
|
||||
new[] { Values.First(v => v.IsRecommended).Value, _serverVersion.ToString() });
|
||||
new[] { Values.First(v => v.IsRecommended).Value, _hostingEnvironment.IISVersion.ToString() });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using System;
|
||||
|
||||
namespace Umbraco.Core.Hosting
|
||||
{
|
||||
public interface IHostingEnvironment
|
||||
@@ -16,6 +18,7 @@ namespace Umbraco.Core.Hosting
|
||||
/// Gets a value indicating whether Umbraco is hosted.
|
||||
/// </summary>
|
||||
bool IsHosted { get; }
|
||||
Version IISVersion { get; }
|
||||
string MapPath(string path);
|
||||
string ToAbsolute(string virtualPath, string root);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace Umbraco.Web.Hosting
|
||||
ApplicationPhysicalPath = HostingEnvironment.ApplicationPhysicalPath;
|
||||
ApplicationVirtualPath = HostingEnvironment.ApplicationVirtualPath;
|
||||
CurrentDomainId = AppDomain.CurrentDomain.Id;
|
||||
IISVersion = HttpRuntime.IISVersion;
|
||||
}
|
||||
|
||||
public int CurrentDomainId { get; }
|
||||
@@ -39,6 +40,9 @@ namespace Umbraco.Web.Hosting
|
||||
public bool IsDebugMode => HttpContext.Current?.IsDebuggingEnabled ?? _hostingSettings.DebugMode;
|
||||
/// <inheritdoc/>
|
||||
public bool IsHosted => (HttpContext.Current != null || HostingEnvironment.IsHosted);
|
||||
|
||||
public Version IISVersion { get; }
|
||||
|
||||
public string MapPath(string path)
|
||||
{
|
||||
return HostingEnvironment.MapPath(path);
|
||||
|
||||
Reference in New Issue
Block a user