2016-06-13 17:42:05 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Web.Configuration;
|
|
|
|
|
|
using Umbraco.Core.Services;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.HealthCheck.Checks.Config
|
|
|
|
|
|
{
|
|
|
|
|
|
[HealthCheck("4090C0A1-2C52-4124-92DD-F028FD066A64", "Custom Errors",
|
|
|
|
|
|
Description = "Leaving custom errors off will display a complete stack trace to your visitors if an exception occurs.",
|
|
|
|
|
|
Group = "Live Environment")]
|
|
|
|
|
|
public class CustomErrorsCheck : AbstractConfigCheck
|
|
|
|
|
|
{
|
2018-11-22 14:05:51 +00:00
|
|
|
|
private readonly ILocalizedTextService _textService;
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2018-11-22 14:05:51 +00:00
|
|
|
|
public CustomErrorsCheck(HealthCheckContext healthCheckContext) : base(healthCheckContext)
|
|
|
|
|
|
{
|
|
|
|
|
|
_textService = healthCheckContext.ApplicationContext.Services.TextService;
|
|
|
|
|
|
}
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2018-11-22 14:05:51 +00:00
|
|
|
|
public override string FilePath
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return "~/Web.config"; }
|
|
|
|
|
|
}
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2018-11-22 14:05:51 +00:00
|
|
|
|
public override string XPath
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return "/configuration/system.web/customErrors/@mode"; }
|
|
|
|
|
|
}
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2018-11-22 14:05:51 +00:00
|
|
|
|
public override ValueComparisonType ValueComparisonType
|
2016-06-13 17:42:05 +02:00
|
|
|
|
{
|
2018-11-22 14:05:51 +00:00
|
|
|
|
get { return ValueComparisonType.ShouldEqual; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<AcceptableConfiguration> Values
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<AcceptableConfiguration>
|
|
|
|
|
|
{
|
|
|
|
|
|
new AcceptableConfiguration { IsRecommended = true, Value = CustomErrorsMode.RemoteOnly.ToString() },
|
|
|
|
|
|
new AcceptableConfiguration { IsRecommended = false, Value = "On" }
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
|
|
|
|
|
public override string CheckSuccessMessage
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2018-11-22 14:05:51 +00:00
|
|
|
|
return _textService.Localize("healthcheck/customErrorsCheckSuccessMessage",
|
|
|
|
|
|
new[] { CurrentValue });
|
2016-06-13 17:42:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override string CheckErrorMessage
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2018-11-22 14:05:51 +00:00
|
|
|
|
return _textService.Localize("healthcheck/customErrorsCheckErrorMessage",
|
2016-06-13 17:42:05 +02:00
|
|
|
|
new[] { CurrentValue, Values.First(v => v.IsRecommended).Value });
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override string RectifySuccessMessage
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2018-11-22 14:05:51 +00:00
|
|
|
|
return _textService.Localize("healthcheck/customErrorsCheckRectifySuccessMessage",
|
2016-06-13 17:42:05 +02:00
|
|
|
|
new[] { Values.First(v => v.IsRecommended).Value });
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-11-22 14:05:51 +00:00
|
|
|
|
}
|