本文介绍了城堡MonoRail&艾玛的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人成功使用Castle MonoRail和ELMAH吗?

Is anyone using Castle MonoRail and ELMAH with success?

我们正在使用许多Resuces向用户显示友好的错误消息,但是如果这样做,则例外

We are using a number of Resuces to present users with friendly error messages, but if we do this the exceptions never get as far as ELMAH as the MonoRail rescue intercepts them.

理想情况下,我们希望用户看到救援情况,但要登录到ELMAH中。

Ideally we want the user to see the rescue, but for the exception to be logged in ELMAH.

有任何想法/指针吗?

干杯,

Jay。

推荐答案

查看Macka发布的链接后,我编写了以下简单的单轨异常处理程序:

After looking at the links Macka posted, I wrote this simple monorail exception handler:

public class ElmahExceptionHandler : AbstractExceptionHandler {
    public override void Process(IRailsEngineContext context) {
        ErrorSignal.FromCurrentContext().Raise(context.LastException);
    }
}

然后我将其注册在web.config的monorail部分中:

Then I registered it in web.config, monorail section:

<monorail>
    <extensions>
        <extension type="Castle.MonoRail.Framework.Extensions.ExceptionChaining.ExceptionChainingExtension, Castle.MonoRail.Framework"/>
    </extensions>
    <exception>
        <exceptionHandler type="MyNamespace.ElmahExceptionHandler, MyAssembly"/>
    </exception>
...
</monorail>

就是这样。

这篇关于城堡MonoRail&amp;艾玛的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-15 04:05