使用Secret Manager工具的ASP .NET Core 1.1 web api

时间:2017-04-06 12:24:18

标签: asp.net .net asp.net-core

我试图在我的.net核心网络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();
}

1 个答案:

答案 0 :(得分:4)

您需要添加相关包才能使用它。该软件包名为Microsoft.Extensions.Configuration.UserSecrets,您可以详细了解here

相关问题