我已使用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并使用了metapackage Microsoft.AspNetCore.All).我已将所有可能的nuget包更新到最新版本.
在.NET Core 1.1中,我以这种方式添加JWT承载认证:
app.UseJwtBearerAuthentication(); // from Startup.Configure()
Run Code Online (Sandbox Code Playgroud)
根据http://www.talkingdotnet.com/whats-new-in-asp-net-core-2-0/对于Core 2.0,新方法是致电:
services.AddJwtBearerAuthentication(); // from Startup.ConfigureServices()
Run Code Online (Sandbox Code Playgroud)
但是方法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'
Run Code Online (Sandbox Code Playgroud)
请帮忙.