在 .net Core 的 Use() 方法中使用 next() 方法?
Use of next() method in Use() method in .net Core?
如果我不在请求管道的Use()方法中调用next()方法或next.Invoke()会发生什么,它会不会调用下一个中间件组件?
来自 docs,强调我的:
Chain multiple request delegates together with Use. The next parameter represents the next delegate in the pipeline. You can short-circuit the pipeline by not calling the next parameter.
并且:
When a delegate doesn't pass a request to the next delegate, it's called short-circuiting the request pipeline. Short-circuiting is often desirable because it avoids unnecessary work. For example, Static File Middleware can act as a terminal middleware by processing a request for a static file and short-circuiting the rest of the pipeline.
因此,如果您不调用下一项,管道将在那里停止。
如果我不在请求管道的Use()方法中调用next()方法或next.Invoke()会发生什么,它会不会调用下一个中间件组件?
来自 docs,强调我的:
Chain multiple request delegates together with Use. The next parameter represents the next delegate in the pipeline. You can short-circuit the pipeline by not calling the next parameter.
并且:
When a delegate doesn't pass a request to the next delegate, it's called short-circuiting the request pipeline. Short-circuiting is often desirable because it avoids unnecessary work. For example, Static File Middleware can act as a terminal middleware by processing a request for a static file and short-circuiting the rest of the pipeline.
因此,如果您不调用下一项,管道将在那里停止。