【发布时间】:2023-03-25 19:42:01
【问题描述】:
我正在了解 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?我正在使用 VS 2017。我遇到了同样的问题。但是,即使显示此问题,它也会构建。我按照@Jeremy Cook 的建议关闭并打开了 VS 2017,问题就消失了。
-
Vs2017。在 vs2015 中有同样的问题。重启 ide 没有帮助