MVC 3 getting values from AppSettings in web.config

前端 未结 2 1616
梦谈多话
梦谈多话 2021-02-11 16:08

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:24

    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"]; }    
    }
    

提交回复
热议问题