Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have a remote procedure call API where the connection parameters need to be stored somewhere that the API code can access. This API is expected to be used mainly to create web services.

I originally planed to store these parameters in a separate xml file, and require users of the API to define the path to that file in code. A coworker has suggested that I should find a way to store these parameters in the web.config file instead.

Without a lot of WCF experience, I am under the impression that the web.config file should not be used here, because it contains many settings necessary for a web service or web app to function. I don't want my API to mess with that file. I feel it is too risky.

What is your opinion on this? Is web.config an appropriate place for storing settings for my API, or should it be left alone?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

In my experience with .NET programming, the web.config (for WCF and ASP.NET) or the app.config (for all other .NET projects) are used for anything that is related to the configuration of the application or framework. There are exceptions such as when the amount of configurations is just too exceedingly large to organize well into one file, however I'd recommend that you try to stay away from that if at all possible.

You would be correct that a lot of WCF-specific configuration (service endpoints and what not) are currently in the web.config file. However, the web.config file is meant to hold much much more including configurations for any plugins you may be using like cache-solutions or db-connection info (Entity Framework being what comes to mind).

I would recommend that you explore what you can do (by default) with the web.config outside of WCF. Also, it may be worth noting that you can define your own configuration elements so that you're not just throwing everything into appSettings. Check out this link for a simple tutorial on creating your own config sections:

http://www.4guysfromrolla.com/articles/020707-1.aspx

As far as your particular scenario is concerned, I feel that it would be an excellent idea to define your configurations within the Web.config file. Just make sure that you keep it cleaned and organized as it grows with your application (so you don't inadvertently make unwanted changes).

share|improve this answer
    
Thank you very much for the insight. I guess I just need to make sure the name of the config sections I add to the web.config file is unique enough that it doesn't affect other things. –  Zoomzoom Feb 17 '13 at 2:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.