Skip to main content
Inspiring
June 29, 2023
Answered

cfinclude writes code as plain text to web page

  • June 29, 2023
  • 1 reply
  • 1915 views

I'm in the process of trying to migrate from Coldfusion 2018, to Coldfusion 2021. And after what seems like a successfull migration, I am encoutring weird behavoir for cfincludes.
The code in the .cfm file, that is included, is written out as plain text to the webpage, this being a cfquery, and the tag and contents of a cfscript-tag.

The code itself worked when on Coldfusion 2018, so this is probably due some setting I have not set, but I could not find anything.

    This topic has been closed for replies.
    Correct answer Nils Michael30768974lfrb

    SOLVED: During the installation of the new version of ColdFusion 2021, the setting for `Allowed file exstensions for CFInclude tag`, did not include CFC, which was added in the previous version. Adding CFC made things work as excepcted.

    1 reply

    Charlie Arehart
    Community Expert
    Community Expert
    June 29, 2023

    There is no new or changed behavior I know of that would relate to what you're reporting. But I think we can get to the bottom of your problem.

     

    1. Can you confirm first that there is cfml on the page DOING the cfinclude that does render? If not, then this is not about the cfinclude but rendering of cfml at all. (You might feel that "it must work", but really just try it as a sanity check. Maybe the page doing the include doesn't currently do other cfml. Just add a cfoutput/cfdump of the now() function, for instance. )

     

    2. Indeed, take your current code out of the picture and setup instead a simple two-file test, doing the above. Better still, put those in their own folder with a blank application.cfm (or cfc), to rule out impacts of other application files in folders above it. 

     

    3. If this "still fails", consider putting that test folder (with its 3 files) in another website root, in case somehow there's a factor related to the web server configuration. Lastly, you could put the test folder in the cfusion/wwwroot folder and call it as localhost:8500/testfolder/, which would instead run it via cf's built-in web server and NOT your regular web server--so as to rule that out as another sanity check.

     

    Please let us know how these go, which should take only minutes (and the first one, alone, may show it's not about the cfinclude at all. If it is, the other two are important.)

     

    And if none of the above work, please share the code you come up with.

     

    (You could even use cffiddle.org to test outside your environment. It supports multi-file "applications" if you login--and one of the two login options there does work. That may confirm the code DOES work as expected there, in which case it proves you have some environmental challenge on your end. If it fails there, you could share the url for that application, for us to look at.)

    /Charlie (troubleshooter, carehart. org)
    Inspiring
    June 30, 2023

    1.
    I added a `writeOutput("TEST INCLUDER");`, to the file that is including, and a `writeOutPut("TEST INCLUDANT");` to the file being included, this outputted "TEST INCLUDER" and "writeOutPut("TEST INCLUDANT");".

    2.
    After doing the two-file-test, it worked as normal, the included code was excecuted, and only writeOutput, outputted things to the webpage. It made no difference having a blank application.cfm or application.cfc file in the test-folder.

    To futher clarify, in the original file, the included-file's content is not parsed/executed, so statements like `test = 1 + 3;` are also "pasted" as plain text to the page.

    Nils Michael30768974lfrbAuthorCorrect answer
    Inspiring
    June 30, 2023

    SOLVED: During the installation of the new version of ColdFusion 2021, the setting for `Allowed file exstensions for CFInclude tag`, did not include CFC, which was added in the previous version. Adding CFC made things work as excepcted.