ConfigurationManager.AppSettings[ "AudienceSecret" ] 在 asp.net 中返回 null



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

我遵循了本教程的每一步。

" ConfigurationManager。AppSettings["AudienceSecret"]"这一行返回null

据我所知,这一行返回服务器的秘密。

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

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

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

在您提供的链接中,它是"as:AudienceSecret"。只要确保你没有打错字就行。它返回空值,因为它没有在web中找到所提供的键及其相应的值。配置文件。

最新更新