私は単純に次のように何かをしたいと思います:codeからcustomErrorsのdefaultRedirect値を取得するにはどうすればよいですか?
web.configファイル内のコースのvar defaultRedirectUrl = SomeMethodToGetDefaultRedirect();
私はこれを行う方法を
<customErrors mode="On" defaultRedirect="~/Error"/>
がありますか?
私は単純に次のように何かをしたいと思います:codeからcustomErrorsのdefaultRedirect値を取得するにはどうすればよいですか?
web.configファイル内のコースのvar defaultRedirectUrl = SomeMethodToGetDefaultRedirect();
私はこれを行う方法を
<customErrors mode="On" defaultRedirect="~/Error"/>
がありますか?
(MSDNからコピー)役立つはずありがとうマーク、それは参考になりました。 私が本当に尋ねたかったのは、 "asp mvc appのweb.configからcustomErrorsセクションの" defaultRedirect "プロパティを取得する方法でしたか?"
そして、あなたのポストに基づいて答えは、次のとおりです。
CustomErrorsSection customErrorsSection = (CustomErrorsSection) ConfigurationManager.GetSection("system.web/customErrors");
string defaultRedirect = customErrorsSection.DefaultRedirect;
私が正しくあなたの質問を理解していれば、これは
// 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;