【发布时间】:2018-01-24 12:12:30
【问题描述】:
我已使用来自https://blogs.msdn.microsoft.com/webdev/2017/08/14/announcing-asp-net-core-2-0/ 的说明将我的项目从 Core 1.1 更新到 Core 2.0 (将目标框架更新为 .NET Core 2.0 并使用元包 Microsoft.AspNetCore.All)。我也已将所有可能的 nuget 包更新到最新版本。
在 .NET Core 1.1 中,我以这种方式添加 JWT 不记名身份验证:
app.UseJwtBearerAuthentication(); // from Startup.Configure()
根据 http://www.talkingdotnet.com/whats-new-in-asp-net-core-2-0/ 对于 Core 2.0,新方法是调用:
services.AddJwtBearerAuthentication(); // from Startup.ConfigureServices()
但是方法 AddJwtBearerAuthentication() 不存在。 Microsoft.AspNetCore.Authentication.JwtBearer 2.0.0 包已安装。
新的空 Core 2.0 项目(带有 JwtBearer 包)也没有 IServiceCollection 的扩展方法 AddJwtBearerAuthentication()。
旧方法 app.UseJwtBearerAuthentication() 根本无法编译:
Error CS0619 'JwtBearerAppBuilderExtensions.UseJwtBearerAuthentication(IApplicationBuilder, JwtBearerOptions)' is obsolete: 'See https://go.microsoft.com/fwlink/?linkid=845470'
请帮忙。
【问题讨论】:
标签: authentication jwt bearer-token .net-core-1.1 .net-core-2.0