2009-09-02 2 views

답변

13

.. .

는 HttpContext.Current.IsCustomErrorEnabled

3

당신은 사용자 정의 오류가 차단 얻기 위해 그것을 사용 후, 웹 사이트에 대한 구성을 얻기 위해 WebConfigurationManager.OpenWebConfiguration을 사용할 수 있습니다 : 나는 그것에서의 수행하는 방법을 알아 냈어요

Configuration configuration = 
    WebConfigurationManager.OpenWebConfiguration(null); 

CustomErrorsSection customErrorsSection = 
    configuration.GetSection("system.web/customErrors") as CustomErrorsSection; 

Response.Write(customErrorsSection.Mode.ToString()); 
+0

'OpenWebConfiguration (널)를'현재 응용 프로그램의 Web.config를하지만 컴퓨터에 설치된의 Web.config를로드하지 않는 것 같습니다. 다른 대답은'OpenWebConfiguration ("~")'을 보여 주지만 나는 확인하지 못했습니다. – Buildstarted

0

OpenWebConfiguration (TRUE) (널) 또는 HttpContext.Current.IsCustomErrorEnabled는 나에게 잘못된 정보를 준 이 그러나 큰 복사 붙여 넣기 작업 :

public static CustomErrorsMode GetRedirectMode() 
{ 
    Configuration config = WebConfigurationManager.OpenWebConfiguration("/"); 

    return ((CustomErrorsSection)config.GetSection("system.web/customErrors")).Mode; 
} 
관련 문제