* Started moving to JSON instead of config. Mild refactoring but overall keeping it the same, except for injecting IConfiguration and JSON parsing instead of XML Tests currently unaffected, need to increase coverage * Moved to constants for appsettings keys Moved from IConfiguration to global settings - later to be replaced with IOptions Updated translation messages Installed IOptions ready for new PR Updated to new interface, IConfigurationService * Post-merge fix * Namespace move from Umbraco.Web to Umbraco.Core where appropriate * Renamed abstractsettings (from abstractconfig) Moving out of configservice into the POCO config check * Made the IIsCustomErrors healthcheck as obsolete, as no web.config setting). Investigate reintroducing this check in the .NET Core way (UseDevelopment). Reducing use of abstractsettings as not needed - we don't need a config service to read the config settings anymore as they're all explicit POCOs. Consolidated health-checks in project. * Removed test views that weren't meant to be added * Returned to use of abstractsettings with different use * Moved more health checks into correct folder/namespace, and enum into their own file * Correct namespace * Git history/compare lost due to file move, temporarily moving back to original folder. Will do another PR to move after this * Use existing GetStatus in abstract check for Debug mode * Updating to return to previous logic and putting files back into line * Macro errors returned to previous logic * Reuse abstractsettings class * Swapped order to assist with reviewing PR * Updated to include itempath * Not implemented comment to avoid confusion Implemented NotificationEmailCheck * Changed to IOptionsMonitor as per PR comments. Removed configurationservice as we need to rethink the fixing strategy. Updated logger. Needs to show fix message instead of fixing. Temporary fix for IIS version * Switched to IOptionsMonitor for all * No longer attempts to actually fix header in config. Still need to show suggestions. Co-authored-by: Elitsa Marinovska <elm@umbraco.dk>
81 lines
3.2 KiB
C#
81 lines
3.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Options;
|
|
using Umbraco.Core.Configuration.Models;
|
|
using Umbraco.Core.Hosting;
|
|
using Umbraco.Core.Services;
|
|
|
|
namespace Umbraco.Core.HealthCheck.Checks.Configuration
|
|
{
|
|
[Obsolete("This is not currently in the appsettings.JSON and so can either be removed, or rewritten in .NET Core fashion")]
|
|
[HealthCheck("046A066C-4FB2-4937-B931-069964E16C66", "Try Skip IIS Custom Errors",
|
|
Description = "Starting with IIS 7.5, this must be set to true for Umbraco 404 pages to show. Otherwise, IIS will takeover and render its built-in error page.",
|
|
Group = "Configuration")]
|
|
public class TrySkipIisCustomErrorsCheck : AbstractSettingsCheck
|
|
{
|
|
private readonly ILocalizedTextService _textService;
|
|
private readonly ILoggerFactory _loggerFactory;
|
|
private readonly Version _iisVersion;
|
|
private readonly GlobalSettings _globalSettings;
|
|
|
|
public TrySkipIisCustomErrorsCheck(ILocalizedTextService textService, ILoggerFactory loggerFactory, IOptions<GlobalSettings> globalSettings)
|
|
: base(textService, loggerFactory)
|
|
{
|
|
_textService = textService;
|
|
_loggerFactory = loggerFactory;
|
|
//TODO: detect if hosted in IIS, and then IIS version if we want to go this route
|
|
_iisVersion = new Version("7.5");
|
|
_globalSettings = globalSettings.Value;
|
|
}
|
|
|
|
public override string ItemPath => "TBC";
|
|
|
|
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldEqual;
|
|
|
|
public override string CurrentValue => null;
|
|
|
|
public override IEnumerable<AcceptableConfiguration> Values
|
|
{
|
|
get
|
|
{
|
|
// beware! 7.5 and 7.5.0 are not the same thing!
|
|
var recommendedValue = _iisVersion >= new Version("7.5")
|
|
? bool.TrueString.ToLower()
|
|
: bool.FalseString.ToLower();
|
|
return new List<AcceptableConfiguration> { new AcceptableConfiguration { IsRecommended = true, Value = recommendedValue } };
|
|
}
|
|
}
|
|
|
|
public override string CheckSuccessMessage
|
|
{
|
|
get
|
|
{
|
|
return _textService.Localize("healthcheck/trySkipIisCustomErrorsCheckSuccessMessage",
|
|
new[] { Values.First(v => v.IsRecommended).Value, _iisVersion.ToString() });
|
|
}
|
|
}
|
|
|
|
public override string CheckErrorMessage
|
|
{
|
|
get
|
|
{
|
|
return _textService.Localize("healthcheck/trySkipIisCustomErrorsCheckErrorMessage",
|
|
new[] { CurrentValue, Values.First(v => v.IsRecommended).Value, _iisVersion.ToString() });
|
|
}
|
|
}
|
|
|
|
public override string RectifySuccessMessage
|
|
{
|
|
get
|
|
{
|
|
return _textService.Localize("healthcheck/trySkipIisCustomErrorsCheckRectifySuccessMessage",
|
|
new[] { "Not implemented" });
|
|
|
|
//new[] { Values.First(v => v.IsRecommended).Value, _iisVersion.ToString() });
|
|
}
|
|
}
|
|
}
|
|
}
|