Saturday, September 11, 2004

Add custom configuration sections to web.config.

It is good practice not to hard code things that can be placed in configuration files. XML files are very good for that purpose. ASP.NET applications use it natively by web.config. There is even section for application specific needs – appSetting section in web.config file. This section enables storing plain name\value setting, but when it gets to store more complex config structure appSettings section is not enough – better way is to store it in custom XML file, but the best way (of course, as for me) is to store custom configuration in the very same web.config file. For that purpose you can use section handlers provided with .NET Framework such as NameValueFileSectionHandler or SingleTagSectionHandler or even implement your own based on IConfigurationSectionHandler. This video (avail also in hebrew) provides demonstration on how to use the former two section handlers.

0 Comments:

Post a Comment

<< Home