0

我的 try 块中的代码如下所示:

catch (ThinkBusinessLogicException ex)
{
    var message = (ex.InnerException != null) ? ex.InnerException.ToString() : ex.Message;

    if (message == "CustomerID in A does not match customerId in B")
    {
        Error = new ErrorStore("400", "1", "CustomerID in A does not match customerId in B");
        throw new WebProtocolException(HttpStatusCode.BadRequest, Error.Description, Error.Generate(), null, null);
    }

    throw new WebProtocolException(HttpStatusCode.InternalServerError, message, new ErrorStore("500", "1", message).Generate(), null, null);
}

发生的情况是条件被满足并且条件中的 WebProtolException 被满足并抛出。但是,在调试外部 WebProtocolException 时也会抛出“A 中的 WebProtocolException CustomerID 与 B 中的 customerId 不匹配,用户代码未处理”。

但是,当我查看提琴手时,会显示 400 的状态代码,并且在提琴手的原始选项卡上会显示正确的 badrequest 响应和消息。

我很困惑为什么第二个 WebProtocol 没有被用户代码处理。

非常感谢任何建议!

扎尔

4

1 回答 1

0

看看这个问题和答案以及这个ASP.NET 论坛讨论。看来您遇到了同样的问题。

于 2011-07-27T12:11:50.553 回答