JWT Error between app.UseRouting() and app.UseEndpoints(...).
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); //.net core3以上UseAuthentication要在UseRouting上下,以及Endpoint之间,.net core2不用 ///添加jwt验证 app.UseAuthentication(); app.UseRouting(); ///添加jwt验证 app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }