When I publish my Asp.Net MVC website to the production server (via VS2008), the web.config & castle.xml files are overwritten. The content of these files is obviously different between my local dev environment and the production server.
How do I prevent these files from being published?
In order to prevent root settings to be inherited, use inheritInChildApplications attribute in location tag. The location path in the example above is empty. It means that this setting will be applied to the level of the config file and below it.
The machine. config file file is at the highest level in the configuration hierarchy while Web. config file is to override the settings from the machine. config file.
Yes you can have two web. config files in application. There are situations where your application is divided in to modules and for every module you need separate configuration. For example if you have a application which has two modules lets say accounts and sales.
When you edit the web. config, It will restart the AppDomain (NOT AppPool) of that web application and clears the all occupied resources and memory. So other web applications running under that App Pool will not be affected.
In Visual Studio solution explorer, go to your web.config file's properties. Make sure "Build Action" is "None" and "Copy to Output Directory" is "Do not copy".
If you ever want to update it in the future you'll have to do it manually or change "Build Action" back to "Content". The next time you build (or publish) it will overwrite it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With