I'm working on a Web Forms project that has a DLL, and in that DLL there are references to external services. We have 3 environments (development, homologation and production) and for each environment there is a specific URL for each of the services, in its version for the respective environment.
I'm having trouble managing the URLs of these services. In the WebForms project I have web.config
where I can use XML Transformations to store key / value sets, and this would solve my problem. However, in the DLL I only have a app.config
file and it does not support transformations. What is the best way to get my solution adapted to integrate with the correct environment, based only on the Configuration used during the Publish process?
Just to highlight my current template: I create an entry in the Web.Config with the service URL
<add key="UrlServicoCep" value="http://url_dev/servico.asmx" />
Then I retrieve this value and step it as a parameter in the instantiation of the class where the service is used:
string urlServico = ConfigurationManager.AppSettings["UrlServicoCep"];
var dao = new CepDAO(urlServico);
Summary: I want to generate a package for the desired environment (approval or production) and that this package generation already has the correct URL applied to the web services that I use.