We want to move our asp.net settings from web.config to a database. All of the examples I see for开发者_JS百科 SqlSettingsProvider are Winform apps. Can SqlSettingsProvider be used with asp.net? If not, can someone suggest an alternative?
Thanks
According to MSDN the SqlSettingProvider attribute can only be used for classes derived from ApplicationSettingsBase. As this class is Windows Forms specific and this is stated explicitly in the documentation it means you cannot use this functionality in a web context. (See http://msdn.microsoft.com/en-us/library/8eyb2ct1.aspx for details). To work around this and get similar functionality I would advise you to create a custom SettingsProviderBase class and implement the setting storage strategy that you need. Using this approach will also allow you to unit test the classes that are depending on application settings.
精彩评论