I am working with a silverlight app that has a fairly large appsettings section in the web.config. While searching I cannot find any examples of using custom configuration sections with silverlight. I cant be the first to have this problem, in a silverlight environment.
What is the best practice to stop putting config values in the appconfig, and using an approach more akin to custom config sections. Thank you
The
Web.Configis purely for consumption by the web site serving up amongst other things the silverlight application files. The Silverlight application(s) in the web site do not natively have any notion of a “App.config”.For the record one very simply way to create custom sections is to use the
NameValueSectionHandler:-In server-side code you can access values from this section via the
HttpContextobject.The alternative is create your own section handler be creating an implementation of
IConfigurationSectionHandlerwhich simply has aCreatethat accepts anXmlNodewhich is the “myCustom” node.However all of this doesn’t help you client-side. You basically need to invent your own means of providing configuration to the application.
For simple sets of value the
initParamsparameter on the plugin’s object tag is generaly used. If you have more complex settings then invent your own xml structure to hold this data and download that xml on application startup.