VJs Tip Of The Day
Reply
![]() |
|
From:
![]() VishalRJoshi
|
A design consideration to access Web.Config
If you are going to access Web.config file for various configuration settings of yours e.g. ConnectionString.... Then sometimes it would be a good idea to develop a class specially to access configuration settings, something like a ConfigManager... what this class can inturn do is to access Web.Config file in its constructor to retrieve your configuration settings and fill up private variables and in turn expose them as properties...
The advantage of having this approach is that if you decide to change your source for these settings then you do not have to go to every page and change the way you access the settings you just change your class... Other than this there can be potential situations in which you might decide to encrypt some values in your web.config file later... This security enhancement would otherwise cause all your pages accessing this information change... During such situations it would be ideal to have a class like this...
To add icing to the cake you can make required member variables static so that the class's instance need not be created every time... Also do try to make sure that every call to your property should not need to query web.config file to access values or else they may degrade performance...
PS: This is a design tip, it may not be perfect design for all situations these are just some of my generic thoughts, if you have anything to dispute please feel free to drop me an email Vishal Joshi Microsoft MVP .Net If You Think YOU CAN... You Can... http://VishalJoshi.Blogspot.com http://www.microsoft.com/india/mvp/indiamvp.aspx http://groups.msn.com/ChennaiNetUserGroup http://groups.msn.com/CNUG-DAM http://groups.msn.com/NetBloomingtonUserGroup
|
|
View other groups in this category.
![]() |
To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.
Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.
If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.
|
|