What are the differences between app.UseRouting() and app.UseEndPoints()?

后端 未结 5 911
忘掉有多难
忘掉有多难 2021-01-31 14:48

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

5条回答
  •  梦毁少年i
    2021-01-31 15:19

    UseRouting: Matches request to an endpoint.

    UseEndpoints: Execute the matched endpoint.

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

    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.

提交回复
热议问题