2009-09-02 6 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(null)を'現在のアプリケーションが、マシンにインストールweb.configファイルにweb.configファイルをロードしていないようです。他の答えは 'OpenWebConfiguration("〜 ")'と表示されますが、私は確認していません。 – Buildstarted

0

OpenWebConfiguration(ヌル)またはHttpContext.Current.IsCustomErrorEnabled(真)が私に虚偽の情報を与え、これはしかし、偉大な コピーペースト働い:

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

    return ((CustomErrorsSection)config.GetSection("system.web/customErrors")).Mode; 
} 
関連する問題