views:

45

answers:

2

Is it possible to check weather custom errors is turned on or off in the code on web application runtime.

+2  A: 

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());
Programming Hero
+1  A: 

I've figured out how to do it it's in...

HttpContext.Current.IsCustomErrorEnabled

Naz