2012-05-08 4 views

答えて

11

(MSDNからコピー)役立つはずありがとうマーク、それは参考になりました。 私が本当に尋ねたかったのは、 "asp mvc appのweb.configからcustomErrorsセクションの" defaultRedirect "プロパティを取得する方法でしたか?"

そして、あなたのポストに基づいて答えは、次のとおりです。

CustomErrorsSection customErrorsSection = (CustomErrorsSection) ConfigurationManager.GetSection("system.web/customErrors"); 
     string defaultRedirect = customErrorsSection.DefaultRedirect; 
12

私が正しくあなたの質問を理解していれば、これは

// Get the Web application configuration. 
Configuration configuration = WebConfigurationManager.OpenWebConfiguration("/aspnetTest"); 

// Get the section. 
CustomErrorsSection customErrorsSection = (CustomErrorsSection)configuration.GetSection("system.web/customErrors"); 

// Get the collection 
CustomErrorCollection customErrorsCollection = customErrorsSection.Errors; 

// Get the currentDefaultRedirect 
string currentDefaultRedirect = customErrorsSection.DefaultRedirect; 
関連する問題