Merge pull request #11823 from umbraco/v8/bugfix/dont_show_stacktrace_in_production_mode

Don't show stack trace in production mode
This commit is contained in:
Nikolaj Geisle
2022-01-18 17:47:14 +01:00
committed by GitHub

View File

@@ -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;
}
}
}
}