The code 开发者_StackOverflow中文版in my try block looks something like below:
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);
}
What happens is that the condition is met and the WebProtolException in the condition is met and thrown. However while debugging the outter WebProtocolException is also thrown stating that "WebProtocolException CustomerID in A does not match customerId in B was unhandled by user code".
However when I take a look in fiddler the status code of 400 is displayed and on the raw tab in fiddler dispalys the correct badrequest response with the message.
I'm confused to why the second WebProtocol is unhandled by user code.
Any suggestions is much appreciated!
Zal
Take a look at this question and answer and this ASP.NET forum discussion. It seems you are running into the same issue.
精彩评论