For ASP.Net application deployment what type of information (if any) are you storing in the machine.config?
If you're not using it, how are you managing environment specific configuration settings that may change for each environment?
I'm looking for some "best practices" and the benefits/pitfalls of each. We're about to deploy a brand new application to production in two months and I've got some latitude in these types of decisions. I want to make sure that I'm approaching things in the best way possible and attempting to avoid shooting myself in the foot at a later date.
FYI We're using it (machine.config) currently for just the DB connection information and storing all other variables that might change in a config table in the database.
I use machine.config for not just ASP.NET, but for overall config as well. I implemented a hash algorithm (Tiger) in C# and wanted it to be available via machine request. So, registered my assembly in the GAC and added the following to machine.config:
This allows my code to look like so:
and there's no dependency on the Jcs.Tiger.dll assembly in my code at all, hard or soft.
If you load balance your servers, you ABSOLUTELY have to make sure the machine key is the same on all the servers. Viewstate is supposed to be server agnostic, but it is not, so you'll get viewstate corruption errors if the machine key is not the same across servers.
From: http://www.c-sharpcorner.com/UploadFile/gopenath/Page107182007032219AM/Page1.aspx
PS sure you can enableViewStateMAC="false", but don't.
We use machine.config on our production server to set/remove specific configuration that are important for production and we never want to forget to set them.
These are the 2 most important:
We are considering using machine.config to add one key for the environment, and then have one section in the web.config which is excactly the same for all environments. This way we can do a "real" XCopy deployment.
E.g. in the machine.config for every computer (local dev workstations, stage servers, build servers, production servers), we'll add the following:
Then, any configuration element that is environment-specific gets the environment appended, like so:
One problem that we don't have a solution for is how to enable say tracing in web.config for debugging environment and not for live environment.
Another problem is that the live connectionstring incl. username and password is now in your Source Control system. This is however not a problem for us.