从工作单元事务中抑制错误

时间:2018-04-30 16:45:41

标签: c# error-handling transactions unit-of-work aspnetboilerplate

我试图压制代码中的错误,但MVC操作仍然会返回" 500内部服务器错误"。

操作返回后,ASP.NET Boilerplate框架中会触发哪些事件?

public async Task<IActionResult> Post([FromBody]PaymentViewModel model)
{
    var result = false;

    // Storing of card must pass
    try
    {
        // ...
    }
    catch (Exception ex)
    {
        // Catch business exception, but storing
    }

    return Json(new { result });
}

1 个答案:

答案 0 :(得分:1)

要在Private Sub Button1_Click(sender As Object, e As PaintEventArgs) Handles Startpage.Button1.Click End Sub 块中恢复,请使用catch开始UnitOfWork

RequiresNew

进一步说明:aspnetboilerplate/aspnetboilerplate#2732 (comment)