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

前端 未结 3 1112
星月不相逢
星月不相逢 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:02

    It depends on how you debug. If you are using Cassini, afaik your web.config contents will be read regardless of the selected solution configuration (e.g. Debug or Release).

    If you are debugging with your local IIS, it depends on what you have set the path in the IIS to. If you have set it to your source code directory, you need to write your local settings into your web.config. If you publish your code into a local directory and set the IIS path accordingly, you can use web.config transforms. (You said, that your web.config transforms are working)

    For other future readers:
    I'd recommend the following: Have your debug settings in your web.config. Create a solution configuration with "Release" settings (Web.Release.Config), which you use for your publish process.

    Check out http://www.tomot.de/en-us/article/5/asp.net/how-to-use-web.config-transforms-to-replace-appsettings-and-connectionstrings for a step by step tutorial for web.config transforms with VS 2010. Although the publish dialog changed in VS 2012, you should be able to adapt the guide to the newer version.

提交回复
热议问题