In response to my post about the web.config file in ASP.NET, Ray asked how this was any different from Application.cfm in ColdFusion land. I think that it’s very similar, but there are some things that are better about web.config than Application.cfm.
First, and I think most importantly, web.config is a configuration file and a configuration file only. I’ve seen ColdFusion applications that use Application.cfm for security, some to include the header, some that contain database connection strings, some that contain UDF’s, etc. etc… Application.cfm is more flexible in that sense, but as always, that flexibility comes at the cost of misuse. There is no standard way of providing configuration information to a ColdFusion application.
Second, because web.config contains only XML, you can use your favorite XML parser to create and edit your configuration file. You could programatically generate your configuration file if necessary, while an Application.cfm would require a custom script to be written to first parse the file and then another script to write out the file.
Third, web.config files can be included in multiple directories on an application and inherited. You can include Application.cfm files in multiple directories, but you don’t get inheritance unless you explicitly include the parent level Application.cfm.
Fourth, you can programmaticly access configuration information about the current application without reading web.config. You can’t do this AFAIK in ColdFusion. For instance, let’s say that I have an Application.cfm that includes the following tag:
<cfapplication name=”myApplication” clientmanagement=”Yes” sessionmanagement=”Yes”>
and then somewhere later I wanted to know if sessionmanagement is enabled. How would I do that? Can you? Again, as far as I know, you can’t get that information without parsing the Application.cfm and looking for sessionmanagement=”true”. In ASP.NET, I write a simple line of code:
String sessionMode = Session.Mode;
where Session.Mode has the possible values of Off, Inproc, StateServer, and SQLServer.
I think something like what web.config provides would be a really nice addition to Application.cfm. Maybe Application.cfm just stays as it is and we get Application.config in addition…. maybe it’s better that Application.cfm goes away.