app.UseRouting()和app.UseEndPoints()有什么区别? [英] What are the differences between app.UseRouting() and app.UseEndPoints()?

查看:4052
本文介绍了app.UseRouting()和app.UseEndPoints()有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我试图理解它们的过程中,似乎它们都被用来将请求路由/映射到某个端点

As I'm trying to understand them, It seem like they are both used to route/map the request to a certain endpoint

推荐答案

UseRouting :将请求与端点匹配.

UseRouting: Matches request to an endpoint.

UseEndpoints :执行匹配的端点.

它使路由匹配和解析功能与终结点执行功能脱钩,而终结点执行功能迄今都与MVC中间件捆绑在一起.

It decouples the route matching and resolution functionality from the endpoint executing functionality, which until now was all bundled in with the MVC middleware.

这使ASP.NET Core框架更加灵活,并允许其他 在 UseRouting UseEndpoints 之间起作用的中间件.那允许 这些中间件来利用端点路由中的信息, 例如,对 UseAuthentication 的调用必须在 UseRouting ,以便路由信息可用于身份验证决策,并且位于 UseEndpoints 之前,以便用户 在访问端点之前已通过身份验证.

This makes the ASP.NET Core framework more flexible and allows other middlewares to act between UseRouting and UseEndpoints. That allows those middlewares to utilize the information from endpoint routing, for example, the call to UseAuthentication must go after UseRouting, so that route information is available for authentication decisions and before UseEndpoints so that users are authenticated before accessing the endpoints.

这篇关于app.UseRouting()和app.UseEndPoints()有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆