Write custom ASP.NET Core middleware(链接)

下面这篇微软官方文档,介绍了如何在ASP.NET Core中自定义中间件(middleware):

Write custom ASP.NET Core middleware

其中注意这句话:

Additional parameters for the constructor and Invoke/InvokeAsync are populated by dependency injection (DI).

这说明,中间件类中的构造方法(构造函数)、Invoke方法/InvokeAsync方法可以使用依赖注入类型作为额外的参数。

猜你喜欢

转载自www.cnblogs.com/OpenCoder/p/13179453.html