Multiple Environments in ASP.Net MVC 2

I am learning ASP.Net MVC 2 based on PHP and some Rails background, and one of the only things that seem to me is how you manage configuration settings such as connection strings or endpoints for external services.

With the PHP framework used by the previous company, there was a standard format and convention for configuration files. My company was able to use this to make another configuration file loaded based on the environment variable (which was installed in the Apache configuration). This simplified and automated the change of any configuration parameter based on the environment. As far as I know, Rails has some version of the built-in function.

I am familiar with the app.config and web.config files in the .Net world, but is there a way to change these changes based on the environment, preferably automatically, and with different levels of detail? The whole configuration system seems very anemic compared to what I'm used to.

I could probably hack something together to achieve this, but I wanted to see what approach people take in practice, or if there are some standard tools that people use.

+6
development-environment production-environment configuration asp.net-mvc-2
source share
4 answers
+1
source share

There is a web.config conversion .

I am most likely mistaken, but it seems to me that they will not be applied if you simply start the application using the โ€œStart Debugging (F5)โ€ button in Visual Studio, which makes this function inappropriate for many applications.

+3
source share

Obviously, you can run your environment in Debug and Release mode. The ENV variable in Rails and similar conventions in PHP is clearly one of their strengths. As with any choice, theres is always a compromise, and this is one of them. When I'm on the rails, I can evaluate the possibility of loading your ENV variable (test, dev, production ...) with the corresponding gems, etc. Wow. When I am on the rails, they also have a significant difference between VS intellisense, probably the best of them.

However, some of the tricks I saw were encoding in MachineName properties to the corresponding connection strings, etc., so WebConfigs can be easily transferred between different developers and servers, etc.

0
source share

Personally, I use machine.config to manage environment settings. This file contains settings for a specific computer.

If you do not have dedicated machines for each environment, but instead use different websites in IIS, you may have the root.config root file located at the root of each website that contains specific environment settings.

Basically, this global configuration file stores key / value pairs containing the names of my SQL Server, web services server ... that change in different environments, and then in my application I use these keys to build the final connection strings, http web addresses ...

Once these global settings are set, you can deploy the same application files using web.config among all environments.

0
source share

All Articles