Is it possible to check weather custom errors is turned on or off in the code on web application runtime.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web. config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
CustomErrors supports the following modes: On – If defaultRedirect is specified, they will see that content. Otherwise, the default error screen with fewer details. Off – Detailed error details will be shown to the user. (the “yellow screen of death screen”)
The <customErrors> element under system. web in web. config is used to configure error code to a custom page. It can be used to configure custom pages for any error code 4xx or 5xx.
I've figured out how to do it it's in...
HttpContext.Current.IsCustomErrorEnabled
You can use WebConfigurationManager.OpenWebConfiguration to obtain the configuration for the website, then use that to get the custom errors block:
Configuration configuration =
WebConfigurationManager.OpenWebConfiguration(null);
CustomErrorsSection customErrorsSection =
configuration.GetSection("system.web/customErrors") as CustomErrorsSection;
Response.Write(customErrorsSection.Mode.ToString());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With