0

In my .NET website project, I need to set up the Web.config file for different environments. I read that website projects do not support different environments so the config files will not be nested. I manually set up a Web.myEnv.config file and made some additions to the file, but the file is not nested under the Web.config file (only the Web.debug.config file is). Is my new Web.myEnv.config file going to work even though it is not nested? I am unable to try this myself as I can't access the environment I am setting up the configuration for.

Hooman Bahreini
  • 14,480
  • 11
  • 70
  • 137
brett
  • 261
  • 1
  • 5
  • 16
  • Which version of `.net` is this for? – nurdyguy Nov 06 '19 at 17:30
  • @nurdyguy version 4.8 – brett Nov 06 '19 at 17:48
  • 1
    @brett, no. Only one .config file will be read in runtime, namely `web` or `app` config. To use a different one, you should try transforming it in build-time. Refer to https://blog.elmah.io/web-config-transformations-the-definitive-syntax-guide/ for more info. – Eric Wu Nov 06 '19 at 18:07
  • @EricWu I am not using .net core. The web site project doesn't let me nest an environment specific config file. So I don't know if it will be read even though it is not nested. – brett Nov 06 '19 at 18:14
  • Does this answer your question? [How do you handle multiple web.config files for multiple environments?](https://stackoverflow.com/questions/592672/how-do-you-handle-multiple-web-config-files-for-multiple-environments) – Selim Yildiz Nov 06 '19 at 18:59
  • @SelimYıldız No, because on a web site project I can't have different Web.config files. I really need a way to change the configuration only in a specific environment in one Web.config file, not have multiple files. – brett Nov 06 '19 at 19:07

0 Answers0