为什么控制器设置了[Authorize]请求的时候返回404?

在控制器上设置了[Authorize]请求的时候返回404,注释掉之后就能请求成功
请教各位这是哪里出问题了呢?


public class Startup
{

    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddControllers();

        services.AddIdentity<IdentityUser, IdentityRole>(options =>
            {
                options.SignIn.RequireConfirmedAccount = true;
            })
            .AddEntityFrameworkStores<ApplicationDbContext>()
            .AddDefaultTokenProviders();

        services.AddAuthorization();
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }

        app.UseHttpsRedirection();

        app.UseRouting();

        app.UseAuthentication();

        app.UseAuthorization();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
        });
    }
}

    //[Authorize( AuthenticationSchemes = "Identity.Application")]  try and not work
    [Authorize] try and not work
    [ApiController]
    [Route("[controller]/[action]/{id?}")]
    public class LoginController : ControllerBase
    {
        
        [HttpGet]
        public async Task<object> LoginAsync()
        {
            some codes
        }

HTTP 404 或 Not Found 錯誤訊息是 HTTP 的其中一種「標準回應訊息」( HTTP状态码 ),
此訊息代表客戶端在瀏覽網頁時,伺服器無法正常提供訊息,或是伺服器無法回應且不知原因。
通常是因为用户所访问的对应网页已被 刪除 、移动或从未存在。
.
基本判斷是請求的 url 不對。
可以嘗試使用瀏覽器測試伺服器的回復。
.
參考:
HTTP 404 - 维基百科,自由的百科全书
https://zh.wikipedia.org/wiki/HTTP_404

添加服务的顺序可能有问题?参考下这个问题,和你的很像: