bookmarker bookmarker - 1 year ago 78
ASP.NET (C#) Question

How will be visual studio deployment scnerio

I consumed about deployment for my projects. For example I am developing a web api or 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?

Answer Source

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:

<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\sample.mdf;Initial Catalog=sample;Integrated Security=True" providerName="System.Data.SqlClient" />

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" />

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download