How to have different web.config settings for my local machine?

前端 未结 3 1131
星月不相逢
星月不相逢 2020-12-06 18:14

I\'m finding myself having to manually update my DefaultConnection connection string in my web.config when I run locally. How can I automatically detect when I\'m running l

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-06 19:00

    You need to add a solution configuration in order to add web.config transformations.

    • Right click on your solution (in solution explorer)
    • Select "Configuration manager" and in the "Active solution configuration" dropdown, click on new.
    • Enter a configuration name (like "local" for instance)
    • Copy settings from debug (seems more appropriate for development)
    • Check "Create new projects configuration".

    Set your projects configuration aswell, and when you're done, right click on the web.config, select "add transforms" and you're good to go !

    Then, when you want to use your local connection string, just use this configuration instead of debug.

提交回复
热议问题