Skip to content

ASP0001 warning (UseAuthorization should appear between UseRouting and UseEndpoints is incorrectly reported when middleware is nested in app.Map #50880

Description

@vsfeedback

This issue has been moved from a ticket on Developer Community.


The warning “The call to UseAuthorization should appear between app. UseRouting and app. UseEndpoints(…) for authorization to be correctly use”. is incorrectly reported in the below scenario:

        app. Map("/api", api =>
        {
            api. UseRouting();
            api. UseAuthentication();
            api. UseAuthorization();
            api. UseEndpoints(endpoints =>
            {
                endpoints. MapControllers()
               . RequireAuthorization();
            });
        });

This code does not evoke the warning if placed outside the Map block


Original Comments

Feedback Bot on 9/18/2023, 08:18 PM:

(private comment, text removed)


Original Solutions

(no solutions)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    analyzerIndicates an issue which is related to analyzer experiencearea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcbugThis issue describes a behavior which is not expected - a bug.

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions