在Azure的網站,我總是用下面的代碼從配置的應用程序設置取一些值:CloudConfigurationManager vs WebConfigurationManager?
string property = WebConfigurationManager.AppSettings["property"];
就在幾天前,我stublemd在CloudConfigurationManager,有了它,我可以得到這樣的屬性所以:
string property = CloudConfigurationManager.GetSetting("property");
雖然CloudConfigurationManager似乎更適合雲使用,但我從來沒有任何與WebConfigurationManager有關的問題。
- 我應該使用CloudConfigurationManager嗎?
- 這兩者之間有什麼不同?
- CloudConfigurationManager會在哪些情況下表現出不同於
WebConfigurationManager?
但CloudConfigurationManager工作正常,並使WebConfigurationManager的工作 - 我的問題中的代碼工作。 –
是的,根據[msdn](https://msdn.microsoft.com/en-us/library/microsoft.windowsazure.cloudconfigurationmanager.aspx),它也可以工作,它有點「獎勵」邏輯。因此,如果您打算僅使用Azure,則可以將它用於web.config和cscfg設置,但如果您想從Azure切換,則需要對其進行更改。 – Lanayx