我正在学习IdentityServer4 https://identityserver4.readthedocs.io/en/release/quickstarts/0_overview.html,但似乎在使它工作时遇到问题。
创建项目的API部分并进行相应配置后:
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
Authority = "http://localhost:5000",
RequireHttpsMetadata = false,
ApiName = "api1"
});
app.UseMvc();
}
我收到以下错误:
'IApplicationBuilder' does not contain a definition for 'UseIdentityServerAuthentication' and no extension method 'UseIdentityServerAuthentication' accepting a first argument of type 'IApplicationBuilder' could be found (are you missing a using directive or an assembly reference?)
有什么建议我在这里想念吗?
编辑1:
我注意到,即使已安装和存在该软件包,我也无法引用该命名空间。
即
using IdentityServer4.AccessTokenValidation;
要么
using IdentityServer4;
最佳答案
好吧,我刚刚关闭并重新打开了Visual Studio 2017,问题就消失了。也许Visual Studio第一次在拉下IdentityServer4.AccessTokenValidation包时感到cho恼,然后重新打开该项目导致它再次尝试,这次成功了。