I am working to implement a Web API solution for development. I have a few C# console apps that run on a server and have their own data access operations, as well as a MVC app running on a similar server. I want to centralize the DAL to a WEB API that can be hosted somewhere. My question is, what is the best way to manage connection strings and QA/PROD/DEV environments? Do i have to publish a DEV/QA/PROD version of the web api for each instance? If i am using Visual Studio to publish my Project, is there an easy way to adjust the configuration file so that it points to the correct Web API instance?


1 Answer 1


Here is the solution i came up with if anyone ran into the same issue:

I ended up publishing three versions of the API for DEV/QA/PROD to various servers. I have a section in my App.Config/Web.Config for the ApiLocation that i read at runtime for any application that needs the API. I then added configurations for QA and PROD, and changed the Config transform files for each of them to update the API Location per the documentation: https://msdn.microsoft.com/en-us/library/dd465318(v=vs.100).aspx

Heres what they look like

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

    <add key="APILocation" value="server/API_QA/"
      xdt:Locator="Match(key)" />


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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