Tutorials » AspNet tutorials »

Configuration File for .NET applications


This article gives an introduction to the configuration files used in .NET applications.


Configuration File for .NET applications



.NET gives an easy way to store configuration information in an Application Configuration File. In the simple implementation, you can store information as Key-Value pairs. For example, consider a case where you use a database in your application. If you hardcode the data base information in your code, you will have a tough time when you have to change this data source. You have to change your source code and re-compile it. This won't work every time you give your product to different customers or when you run your application in different machines!

In earlier days, programmers used to store this information in special files called .ini files or in windows registry. The database information will be stored in the .ini file or registry and application can read the information from these locations. No need to re-compile the code when the values are changed in .ini file or registry. But this is a pain most of the time. It is not fun opening the registry, locate your entries and make appropriate changes. It is quite possible that you may mess up with some important entries in the registry and make your system not run any more. In fact, in secured systems, administrator may deny access to the registry and users will not have the choice to edit the registry at all. Ini files also have some draw backs. We can store only simple string values as key/value pairs.

.NET gives you a simple and easy solution for this problem - the Application Configuration File. This file is usually called as config file.

Each application can have a configuration file, which is actually an XML file. You can use any text editor (including Notepad) to open the configuration file and change the values. The application will load the values from this configuration file and you do not have to change your source code every time you change your data source or any other information stored in the configuration file.

In the simple implementaion, config files allow you to store key-value pairs. But you can extend it to use complex data types in the form of xml.




Next Chapter: App.config for Windows applications
Previous Chapter: Working with Cookies in ASP.NET
More Chapters: ASP.NET Tutorials
More Tutorials: Tutorial Index



Top Contributors
TodayLast 7 Daysmore...

Awards & Gifts

Online Members

SivS
More...
 
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India