I am running into a weird issue with my ColdFusion 10 code. I am new to ColdFusion, so go easy on me. The reason it is weird is because it does not seem to occur in older versions of this platform (i.e. MX 7).
A little info first:
I have two environments. A ColdFusion 10 and a ColdFusion MX 7 (IIS 7 and IIS 5, respectively). In the ColdFusion 10 environment, I have an Application.cfc
file with the following statement...
<cfset CompanyLogoText = "Acme Company">
This Application.cfc
file is in the web root (mydomain.com). I also have a CFM file in a sub folder of the web root at mydomain.com/pages/default.cfm
. It contains the following markup...
<cfoutput><p>#CompanyLogoText#</p></cfoutput>
The issue
When I navigate to mydomain.com/pages/default.cfm
, I get an error from coldfusion. The error is "Variable COMPANYLOGOTEXT is undefined."
The weird part
I am not getting this error in the ColdFusion MX 7. The only difference is that the CF MX 7 environment uses a Application.cfm
file, but with the same exact line.
Question
How can I get the pages/default.cfm
file to see my variable CompanyLogoText
in the CF 10 environment?
Here is the full markup
Application.cfc
<cfcomponent>
<cfset This.name = "test_cf">
<cfset This.Sessionmanagement="yes">
<cfset This.Sessiontimeout="#createtimespan(0,0,10,0)#">
<cfset This.applicationtimeout="#createtimespan(5,0,0,0)#">
<cfset This.setclientcookies="no" >
<cfset This.clientmanagement="no">
<cffunction name="onApplicationStart">
<cfset CompanyLogoText = "Acme Company">
</cffunction>
<cffunction name="onRequestStart">
<cfargument name="requestname" required=true />
<cfset CompanyLogoText = "Acme Company">
</cffunction>
</cfcomponent>
Pages/Default.cfm
<cftry>
<cfoutput><p>#CompanyLogoText#</p></cfoutput>
<cfcatch>
<p>Could not read CompanyLogoText<br/><br/>
<cfoutput>
<br/>Message: #cfcatch.message#
<br/>Details: #cfcatch.detail#.
</cfoutput>
</cfcatch>
</cftry>