我试图在我的.net核心web api应用程序中设置谷歌登录。 我一直在关注此指南: https : //docs.microsoft.com/en-us/aspnet/core/security/authentication/social/google-logins
但由于某种原因,我得到这个错误:
'IConfigurationBuilder'不包含'AddUserSecrets'的定义,并且没有扩展方法'AddUserSecrets'可以找到接受类型'IConfigurationBuilder'的第一个参数(你是否缺少using指令或程序集引用?)
这是我的启动方法,这里没什么特别的:
public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true); if (env.IsDevelopment()) { // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 builder.AddUserSecrets<Startup>(); } builder.AddEnvironmentVariables(); Configuration = builder.Build(); }I a trying to set up google sign in in my .net core web api application. I have been following this guide: https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/google-logins
But for some reason i get this error:
'IConfigurationBuilder' does not contain a definition for 'AddUserSecrets' and no extension method 'AddUserSecrets' accepting a first argument of type 'IConfigurationBuilder' could be found (are you missing a using directive or an assembly reference?)
Here's my startup method, nothing special here:
public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true); if (env.IsDevelopment()) { // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 builder.AddUserSecrets<Startup>(); } builder.AddEnvironmentVariables(); Configuration = builder.Build(); }最满意答案
您需要添加相关包才能使用它。 该软件包名为Microsoft.Extensions.Configuration.UserSecrets ,您可以在此处了解更多信息。
You need to add the relevant package to use it. The package is called Microsoft.Extensions.Configuration.UserSecrets, you can learn more about it here.
更多推荐
'IConfigurationBuilder',using,env,'AddUserSecrets',电脑培训,计算机培
发布评论