c# - 处理 Action 过滤器和 Orchard 框架的异常

标签 c# asp.net-mvc error-handling orchardcms

覆盖 ErrorPage.cshtml 允许您为从 Controller 抛出的异常创建自定义错误页面,有没有办法处理从过滤器抛出的异常?例如,我想要自定义页面以防伪造异常。

最佳答案

您可以使用异常过滤器。只需创建您自己的 FilterProvider 并让它实现 IExceptionFilter。将所有自定义逻辑放在 OnException(filterContext) 方法中。

看看例如。 Orchard.Security.SecurityFilter 的当前实现有一个想法。

关于c# - 处理 Action 过滤器和 Orchard 框架的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16770156/

相关文章:

c# - "dotnet ef database update"以编程方式使用 Entity Framework Core

.net - 使用 Html.TextBoxFor 时可以将文本框设置为只读吗?

python - urllib/urllib2 返回的错误码和实际页面

php - error_reporting(E_ALL)失败,没有日志或错误消息

Python 异常处理和引发

c# - 如何声明新类型

c# - DataGridView 编辑列名

c# - Controller 总是收到空参数

c# - 使用 Ninject 时如何模拟通用 Get 方法并使用 SetUp 方法填充模拟数据库?

c# - 当我从 Azure 更改 AD 中的密码时访问被拒绝