diff --git a/src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs b/src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs index a62df6b5e4..ef07dfcb79 100644 --- a/src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs +++ b/src/Umbraco.Web/WebApi/EnableDetailedErrorsAttribute.cs @@ -1,4 +1,5 @@ -using System.Web.Http; +using System.Web; +using System.Web.Http; using System.Web.Http.Controllers; using System.Web.Http.Filters; @@ -11,7 +12,14 @@ namespace Umbraco.Web.WebApi { public override void OnActionExecuting(HttpActionContext actionContext) { - actionContext.ControllerContext.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; + if (HttpContext.Current?.IsDebuggingEnabled ?? false) + { + actionContext.ControllerContext.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; + } + else + { + actionContext.ControllerContext.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Default; + } } } }