Web.Config
-
Hi All, I am working on a .Net library to be used within the organization. There are lot of configuration settings for the library. Now the question is whether i put all the configuration in the web.config file and access using the configsectionhandler interface or should i put the configuration in a seperate xml file and access using XML DOM. One of the reason i asking this bcos if we change anything in the web.config file the whole application resets which i donot want. Can anyone please tell me which one is a better approach and why ???? Thanxs in advance. Maharishi Bhatia :)
-
Hi All, I am working on a .Net library to be used within the organization. There are lot of configuration settings for the library. Now the question is whether i put all the configuration in the web.config file and access using the configsectionhandler interface or should i put the configuration in a seperate xml file and access using XML DOM. One of the reason i asking this bcos if we change anything in the web.config file the whole application resets which i donot want. Can anyone please tell me which one is a better approach and why ???? Thanxs in advance. Maharishi Bhatia :)
My personal view on this is "neither". Rather structure your library's methods and constructors so that they accept the settings as parameters. Then, it is up to the caller application to either hard-code the values or deal with the config file issue. This approach also makes for easier unit testing your library, because your tests can easily deal with several different testing scenarios.
-
My personal view on this is "neither". Rather structure your library's methods and constructors so that they accept the settings as parameters. Then, it is up to the caller application to either hard-code the values or deal with the config file issue. This approach also makes for easier unit testing your library, because your tests can easily deal with several different testing scenarios.
Hi Steven, Thanxs for the prompt answer. Let me rephrase my question... I have already made the library with librarys method and constructors that accept the settings as parameter. I am trying to make a wrapper class which will read from a settings file so that the developer doesnt have to write any code to pass setting data to the library. So actually i was looking for a solution whether to put the config settings in the web.config file or to put it in a seperate xml file. And which solution will be better... Thanxs in advance. Maharishi Bhatia Nothing is Impossible. Even impossible spells "i m possible"
-
Hi Steven, Thanxs for the prompt answer. Let me rephrase my question... I have already made the library with librarys method and constructors that accept the settings as parameter. I am trying to make a wrapper class which will read from a settings file so that the developer doesnt have to write any code to pass setting data to the library. So actually i was looking for a solution whether to put the config settings in the web.config file or to put it in a seperate xml file. And which solution will be better... Thanxs in advance. Maharishi Bhatia Nothing is Impossible. Even impossible spells "i m possible"
Like you say, web.config is not always the best choice, although it is certainly the easiest. Some options: * Use a generalized config API, like Nini * Use an external config file * Use your own home grown config solution