Skip to content

Remove the importance of app configuration order  #18768

Closed
@steveoh

Description

@steveoh

The problem

I was reading the docs on upgrading a 2.1 app to 3.1 which used endpoint routing and could not figure out why my routes were not being picked up. It turned out that app.UseEndpoints(...) needed to be placed before app.UseSpa(...).

There were many warnings in the migration docs about the configuration order eg:

If the app calls UseStaticFiles, place UseStaticFiles before UseRouting.

For most apps, calls to UseAuthentication, UseAuthorization, and UseCors must appear between the calls to UseRouting and UseEndpoints to be effective.

There were no warnings about endpoints and spa. I had to generate a new SPA template to look at the order to finally figure out what the issue was.

Describe the solution you'd like

It would be great if the order of app.UseX was not so critical to a functioning application. All of the gotchas and warnings would be unnecessary. I know there are technical reasons for pipeline registration but I would think that something could sit in the middle and build the configuration in the proper order.

Since I'm sure you've already discussed this and decided to push this onto the developers, I think some documentation around the endpoints and spa needs to be specifically added. Maybe some sort of ordered master list info graphic of when to register what could help.

I was getting tripped up because the spa static files were being returned instead of the api route even though my use endpoints and use routing configuration were after the use static files and use spa static files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsThis issue tracks updating documentationarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsfeature-platformDeprecated: Cross-cutting issues related to ASP.NET Core as a platform

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions