【问题标题】:ConfigurationManager.AppSettings["AudienceSecret"] returns null in asp.netConfigurationManager.AppSettings["AudienceSecret"] 在 asp.net 中返回 null
【发布时间】:2016-08-18 22:23:40
【问题描述】:

我正在尝试在 ASP.NET Web API 和来自 http://bitoftech.net/2015/02/16/implement-oauth-json-web-tokens-authentication-in-asp-net-web-api-and-identity-2 的 Identity 2.1 中实现 JSON Web 令牌身份验证

我已按照本教程的每个步骤进行操作。

"ConfigurationManager.AppSettings["AudienceSecret"]" 这行返回null

据我了解,此行返回服务器的秘密。

那么,问题是什么,我做错了什么?

【问题讨论】:

  • 确保您的配置文件中有设置。
  • 是的,奇怪的是本教程不包括将 appSetting 添加到您的配置中......很奇怪。
  • 是的,但是,谁能告诉我这个受众秘密的价值是什么?

标签: asp.net asp.net-identity owin


【解决方案1】:

确保您的.config 文件中有匹配的设置密钥

<appSettings>
    <add key="AudienceSecret" value="Enter Value Here" /> 
</appSettings>

【讨论】:

    【解决方案2】:

    在您提供的链接中,它是“as:AudienceSecret”。只要确保你没有做任何错字。它返回空值,因为它没有在 web.config 文件中找到提供的键及其各自的值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-30
      • 2018-10-02
      • 2014-03-08
      • 1970-01-01
      • 2014-08-10
      • 1970-01-01
      • 1970-01-01
      • 2013-09-20
      相关资源
      最近更新 更多