我只想做如下事情:
var defaultRedirectUrl = SomeMethodToGetDefaultRedirect();
当然在 web.config 中我有
<customErrors mode="On" defaultRedirect="~/Error"/>
如何做到这一点?
最佳答案
谢谢马克,很有帮助。 我真正想问的是“如何从我的 asp mvc 应用程序的 web.config 中获取 customErrors 部分的“defaultRedirect”属性?”。
根据您的帖子,答案是:
CustomErrorsSection customErrorsSection = (CustomErrorsSection) ConfigurationManager.GetSection("system.web/customErrors");
string defaultRedirect = customErrorsSection.DefaultRedirect;
关于c# - 如何从代码中获取 customErrors 的 defaultRedirect 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10507939/