Use XML to Store Your App Settings in ASP

XML provides many opportunities to share and store data. One of the most common and simple uses of XML is to use it to store data used by your application.

Every application uses data. The traditional way to store this data was in INI files. Then came registries. Now, more and more applications use XML files to store their app settings.

With ASP, you typically store such data in the Application.Contents collection. Oftentimes, these are hardcoded into the Application_OnStart event. Rather than hardcoding these variables, you can store them in an XML file. Simply access the XML file in the Application_OnStart event to initialize the application variables. The XML file may look like this:


You can also write the code to access the XML file and return an array with prop names and values in a COM component. This allows you to change any value in XML when the app is running and refresh the Application.Contents collection without having to restart the app to run the OnStart event. Simply call the Component’s method to refresh your variables!

ASP.NET uses a similar concept with a pre-created file called web.config for each ASP.NET application. This file simple XML file has a similar structure.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: