- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我只想做如下事情:
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/
在我的 web.config 中,我有: 在 Views/Shared/Error.cshtml 中,我有: @model System.Web.Mvc.HandleErrorInfo
我只想做如下事情: var defaultRedirectUrl = SomeMethodToGetDefaultRedirect(); 当然在 web.config 中我有 如何做到这一点? 最佳
我使用 Asp.net 4。 此处为我的 Web.Config 文件设置。 我需要为任何异常应用 defaultRedirect url,并且仅对 Page Not Found 404
这是我在 web.config 中的错误处理,它不起作用。如果抛出任何异常,它不会重定向到 default.aspx 页面。 是因为我将
我有一个 MVC 4 应用程序,使用自定义 HandleErrorAttribute 仅处理自定义异常。我想拦截默认的 404 和其他非 500 错误页面并用更有吸引力的东西替换它们。为此,我在 We
我试图重定向到自定义错误页面(通过特定 Controller )以处理尚未明确处理的 HTTP 错误代码。 为方便起见,我有以下配置 对于我的 Controller : public class E
我是一名优秀的程序员,十分优秀!