如何对我的本地机器不同的web.config设置? [英] How to have different web.config settings for my local machine?

查看:128
本文介绍了如何对我的本地机器不同的web.config设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现自己不得不手动更新我的DefaultConnection连接字符串中我的web.config,当我在本地运行。我怎么能自动当我在本地运行检测和 - 当我 - 覆盖默认的连接字符串?

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 locally and - when I am - overwrite the default connection string?

我有调试/释放转换工作,但这些都是进行部署。我正在寻找一种方法来添加另一种选择 - 本地 - 如果有任何的方式来做到这一点(或者类似的东西)。

I have debug/release transformations working, but these are for deployment. I'm looking for a way to add another option - "local" - if there's any way to do it (or something like it).

推荐答案

您需要以添加web.config中转换添加一个解决方案配置。

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


  • 右键点击您的解决方案(在Solution Explorer)

  • 选择配置管理,并在活动解决方案
    配置下拉列表中,点击新的。

  • 输入的配置名称(如本地例如)

  • 从调试复印设置(似乎更适合于开发)

  • 选中创建新的项目配置。

设置你的项目配置藏汉,当您完成后,右键单击we​​b.config中,选择添加转换,你是好去!

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.

这篇关于如何对我的本地机器不同的web.config设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆