使用Secret Manager工具的ASP .NET Core 1.1 web api(ASP .NET Core 1.1 web api using Secret Manager tool)

编程入门 行业动态 更新时间:2024-10-26 03:32:57
使用Secret Manager工具的ASP .NET Core 1.1 web api(ASP .NET Core 1.1 web api using Secret Manager tool)

我试图在我的.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',电脑培训,计算机培

本文发布于:2023-08-02 12:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1376912.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工具   ASP   NET   Manager   Secret

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!