Sunday, June 29, 2008

How to Read custom entries from the Web.Config/App.Config file

Today I am going to blog about "How to read custom entries from the Web.Config/App.Config file."

Working as a .Net Developer, there will be many occasions when we want to store some data (Maybe Key/Value Pair) in the configuration file but we dont want to add to the AppSettings. In such situations, I have always found is very easy to store my Config entires in the Custom Config sections in Web.Config files.

I want to read the custom section shown below.




The idea behind reading or writing to the config files is that -- "You should tell the framework how you want your data to be Serialized/Deserialized.

In .Net 2.0 made it very easy to Read/Write config data into the configuration file by providing the functionality in System.Configuration.dll.



Add the entry shown above, in the ConfigSection so that framework can create an instance of the class at runtime using reflection.

I have attached the SourceCode for this application.

Source Code Loc:

http://dotnetdevblog.googlepages.com/ReadCustomConfigSections.zip

If you like/dislike something, feel free to leave comments.

Thanks,
Yash

0 comments: