-
Hello everyone During learning the difference between EndpointRoutingMiddleware and EndpointMiddleware, I still don't understand why we change where to put endpoint registration from UseRouting to UseEndpoint. My curiosity has started from reading this blogpost Understanding ASP.NET Core Endpoint Routing From v3.0.0-preview4-19216-03 to v3.0.0-preview3-19153-02, we changed endpoint registration from UseRouting to UseEndpoint and here is the PR that changes endpoint registration. The author of this PR described the purpose but I still don't understand it. Here is the flow that I understand, please correct me if it is incorrect.
This makes me feel like the code jumps from EndpointMiddleware to EndpointRoutingMiddleware Therefore, could you please explain me more about this change? Thank you so much. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
"This is vital because it puts your code visually at the point of the pipeline where it executes." The goal was to make the linear flow of startup intuitive, especially when you add middleware. Consider this example:
UseEndpoints is where routes are specified to help indicate that middleware like UseAuthentication and UseAuthorization will run before the endpoints are executed.
I don't quite understand the concern here. EndpointRoutingMiddleware selects a route/endpoint and then EndpointMiddleware executes it. The pause in between lets other middleware see what endpoint was selected and react if they need to. |
Beta Was this translation helpful? Give feedback.
"This is vital because it puts your code visually at the point of the pipeline where it executes."
The goal was to make the linear flow of startup intuitive, especially when you add middleware.
Consider this example:
UseEndpoints is where routes are specified to help indicate that mid…