Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: XML, ASP
Expertise: Intermediate
Aug 6, 2003

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:


<Properties>
<Property>
<Name>PropName1</Name>
<Value>PropValue1</Value>
</Property>
<Property>
<Name>PropName2</Name>
<Value>PropValue2</Value>
</Property>
</Properties>
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.

Jatin Shah
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap