检查后
MiddlewareFilterBuilder implementation
看起来这是一种“预期”行为。。。
// Ideally we want the experience of a middleware pipeline to behave the same as if it was registered,
// in Startup. In this scenario an exception thrown in a middelware later in the pipeline gets propagated
// back to earlier middleware.
// So check if a later resource filter threw an exception and propagate that back to the middleware pipeline.
if (!resourceExecutedContext.ExceptionHandled && resourceExecutedContext.Exception != null)
{
throw resourceExecutedContext.Exception;
}
这就解释了为什么你会看到
System.Exception: Test Exception
at Microsoft.AspNetCore.Mvc.Internal.MiddlewareFilterBuilder.<>c.<<BuildPipeline>b__8_0>d.MoveNext()
System.Exception: Test Exception
at MyProject.MyRepository.<Fetch>d__9.MoveNext()
还注意到,上述代码位于dev分支中,但不在中的master分支中
aspnet/Mvc
回购。。。