简体   繁体   中英

Can't add IdentityServer4 NuGet package to ASP.NET Core project properly and VS Code is not showing intellisense

I've added IdentityServer4 NuGet package to ASP.NET core project using dotnet cli. Then written the following code on Startup class.

public void ConfigureServices(IServiceCollection services)
    {           
        services.AddIdentityServer()
            .AddInMemoryClients(new Client[] 
                { 
                    new Client
                    { 
                        ClientId = "react client", 
                        ClientName = "React Client",
                        AllowedGrantTypes = GrantTypes.Implicit,
                        RedirectUrls = {"http://localhost:51009/"},
                        AllowedScopes = { "openid"}
                    }
                });            
        services.AddMvc();
    }

Then when I build the project it shows error: The type or namespace name 'Client' could not be found (are you missing a using directive or an assembly reference?)

Moreover VS Code doesn't show any suggestion for IdentityServer related code.

And when I search IdentityServer4 on NuGet website it shows result like following: 在NuGet网站上的搜索结果




And when I search IdentityServer4 on Visual Studio 2017 it shows result like following: Visual Studio 2017上的搜索结果

The IdentityServer4 Client class is located in the IdentityServer4.Models namespace which is included in the nuget-package.

Adding the using-statement where the model/models are needed should resolve the issue

using IdentityServer4.Models

VS Code was not showing intellisense because of an OmniSharp bug. Solution to this problem is restarting OmniSharp.

Ctrl + Shift + P and then type Restart OmniSharp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM