简体   繁体   中英

Web config setting for deployment

In my web.config file, I have a connection string to connect my development database.

 <connectionStrings>
<add name="MembershipDB" connectionString="Data Source=DebugSQL;Initial Catalog=PortalAccess;Integrated Security=True;Application" providerName="System.Data.SqlClient"/>

When I publish the web site to my production server, I just change the Data Source name. When I test it, then I switch it again, is it stupid?

This is quite a common approach and can work well.

Obviously you can run into problems if you get the details wrong while maintaining it by hand this way.

You could also have a look into web.config transformations: This is a way of writing a main web.config file and then writing separate files that change the original depending on the build configuration you run.

Some resources:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM