c# - Nido的ASP.NET C#异常处理

标签 c# asp.net exception error-handling

我正在使用Nido Framework开发我的ASP.NET Web应用程序。它具有默认模式,可记录后端层中发生的所有错误。但是现在我想处理页面级异常并记录它们。我可以使用相同的框架来执行此操作,还是必须寻找其他方法?

任何帮助将不胜感激

最佳答案

如果要在类中记录错误,则可以从“ LoggerBase ”派生该类,如下所示进行异常记录。

public class PaymentGatewayWrapper : LoggerBase
{
    protected override Type LogPrefix
    {
        get { return this.GetType(); }
    }

    public void ProcessPayment(Object paymentInfo, Object customer,
    Guid orderGuid, ref Object processPaymentResult)
    {
        try
        {
            // TODO: Required operational level code
        }
        catch (System.Exception ex)
        {
            this.LogError("Error processing payment", ex);
        }
    }
}

但是,如果要通过网页执行此操作。您将无法选择从自定义类派生它。然后,您可以采取以下另一条路径...
new LogManager(this.GetType()).LogError("This is a test error", ex);

其他引用
  • Gain Coding Speed with Nido (FREE) Framework .NET/ C#
  • ASP.NET/C# Development with Nido Framework for Dummies
  • 关于c# - Nido的ASP.NET C#异常处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26542049/

    相关文章:

    c# - 如果在迭代 IEnumerable 时出现异常(从 Controller 返回),AspNet.Core 将返回 200 OK and invalid Json

    c# - 类不包含采用 0 个参数的构造函数

    c# - 在 MVC 应用程序中卡住使用 Microsoft.Web.WebPages.OAuth.OAuthWebSecurity

    Java/Spring MaxUploadSizeExceededException post 参数

    php - 如何在 zend 框架 2 中邮件传输失败时返回 false?

    c# - 使用 TTS 将 MemoryStream 的音频输出到 Discord Bot

    订阅域事件时的 C# AppDomain 沙箱安全异常

    c# - 是否可以使用 JavaScript 订阅 c# 事件?

    c# - "The operation cannot be completed because the DbContext has been disposed"#2

    wcf - 通过 WCF REST 传递验证异常