Skip to content

I still don't understand why we change where to put endpoint registration from UseRouting to UseEndpoint. #28157

Answered by Tratcher
aaronamm asked this question in Q&A
Discussion options

You must be logged in to vote

"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:

            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });

UseEndpoints is where routes are specified to help indicate that mid…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@aaronamm
Comment options

@Tratcher
Comment options

@aaronamm
Comment options

Answer selected by davidfowl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants