Skip to main content
Inspiring
June 22, 2016
Answered

Which Application.cfc get executed?

  • June 22, 2016
  • 1 reply
  • 636 views

I'm working on a clients system that has a library of CFC's in a folder called /Admin/cfcs.   Inside that folder is an Application.cfc file.

There is also an Application.cfc file at the root directory.  Off the root directory are other folders in addition to the Admin folder.

When I execute the template /Members/Index.cfm a few of the methods from the CFC library get executed.

If there aren't any calls to the CFC library I'm 100% sure the Application.cfc in the root folder gets executed when I run any of the templates in any folder off  the  root folder.

My question is if a template, such as /Members/Index.cfm, invokes a method from the CFC library does the Application.cfc template in the /Admin/cfcs folder get executed or is the root Application.cfc the one executed.

I believe it's just the root one but I'm not 100% sure. 

Any thoughts???  Does having an Application.cfc in the library folder cause any issues???

Thanks in advance for the assist!

    This topic has been closed for replies.
    Correct answer WolfShade

    Your assumption is correct.  The application.cfc in /Admin/cfc is not being executed, at all, unless there is a .cfm file that is being somehow utilized.  The CF Server first searches the current .cfm document folder for application.cfc/cfm; if it doesn't find it, it keeps recursively searching lower and lower folders until it finds an application.cfc/cfm and executes it.  CFCs in a folder with an application.cfc/cfm do not execute another application.cfc/cfm; they rely on the one that was already executed before loading the requested .cfm file.

    HTH,

    ^_^

    1 reply

    WolfShade
    WolfShadeCorrect answer
    Legend
    June 22, 2016

    Your assumption is correct.  The application.cfc in /Admin/cfc is not being executed, at all, unless there is a .cfm file that is being somehow utilized.  The CF Server first searches the current .cfm document folder for application.cfc/cfm; if it doesn't find it, it keeps recursively searching lower and lower folders until it finds an application.cfc/cfm and executes it.  CFCs in a folder with an application.cfc/cfm do not execute another application.cfc/cfm; they rely on the one that was already executed before loading the requested .cfm file.

    HTH,

    ^_^

    Inspiring
    June 24, 2016

    That's what I thought too.  I just wanted to be sure there wasn't anything special happening behind the scenes when including a file from a directory that also has an App.cfc file.

    Thanks!