public
Created

  • Download Gist
DuplicateCustomErrors.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
var config = (CustomErrorsSection)
ConfigurationManager.GetSection("system.web/customErrors");
 
IncludeErrorDetailPolicy errorDetailPolicy;
 
switch (config.Mode)
{
case CustomErrorsMode.RemoteOnly:
errorDetailPolicy
= IncludeErrorDetailPolicy.LocalOnly;
break;
case CustomErrorsMode.On:
errorDetailPolicy
= IncludeErrorDetailPolicy.Never;
break;
case CustomErrorsMode.Off:
errorDetailPolicy
= IncludeErrorDetailPolicy.Always;
break;
default:
throw new ArgumentOutOfRangeException();
}
 
GlobalConfiguration.Configuration.IncludeErrorDetailPolicy
= errorDetailPolicy;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.