MVC 3 getting values from AppSettings in web.config

前端 未结 2 2061
长情又很酷
长情又很酷 2021-02-11 15:46

In normal ASP.NET Web forms sites I would use web.configs \"appsettings\" to add application setting data to a site. However, I am not able to retrieve setting values this way w

2条回答
  •  广开言路
    2021-02-11 16:39

    Are you ever calling set? I'm guessing it never gets called, so the private variable never gets the value from the config.

    Try it this way (just retrieve the value in the get, no set needed):

    public string ClientSecret
    {    
      get { return System.Configuration.ConfigurationManager.AppSettings["ClientSecret"]; }    
    }
    

提交回复
热议问题