I consumed about deployment for my projects. For example I am developing a asp.net web api or asp.net mvc project on visual studio. I use local database and local file usernames and password for ssl. I finish the development and publis it on my local iis server and see the working application. After local iis test, I load it to server but sometimes forget the change web.config settings, connectionstrings, ssl certificate paths and password. So the working server application that users accessed fails. How can I solve this problems?
What I do is I replace the configuration in the Web.Release.config using Transform
So if for example in my Web.config I have the following connection string:
<connectionStrings> <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\sample.mdf;Initial Catalog=sample;Integrated Security=True" providerName="System.Data.SqlClient" /> </connectionStrings>
In my Web.Replace.config I update the connectionString for production like this:
<connectionStrings xdt:Transform="Replace"> <add name="DefaultConnection" connectionString="SERVER_CONNECTION" providerName="System.Data.SqlClient" /> </connectionStrings>
Though keep in mind that the Transformation that I did in Web.Replace.config only applies when you publish your web app. You won't be able to test it locally by just running your application in Debug/Release mode