HTTP Implementation Sketchy in CF 5?

Tweet

…posted by davidjmedlock:

Okay, this is a bit of an annoyance. I was writing an application for managing logos in a system where many clients log in. We’d get the client ID, retrieve the most recent logo and display it. The problem was, this system was written in ColdFusion, but had to be used in a .Net app, as well.

No problem, I thought. I can use CFCONTENT to return this as an image and all they have to do is put the URL to the CF template path in their IMG SRC attribute, like this:



Then in the CF template, I’d do this:





But, does this work in ColdFusion 5? No! Apparently CF 5 has some issues with its HTTP implementation. Whenever I did the tag in an actual application, it ended up not loading the image. When I went directly to that page, I just got a blank page.

Now, I’ve talked with another developer that had attempted something vaguely similar to this before and had problems with CF handling HTTP. If I run this code:


gif.html:


returngif.cfm:

It works okay. Now, I know some are going to say “Did the file that you were trying to return actually exist ?” Yes it did. I double, triple and quadruple checked that. I checked everything I could think of, making sure the file existed, that it was returning the correct MIME type, etc. etc. etc. Still no luck. Ah well, just one more query for the .Net guy to run…

BTW – I haven’t forgotten about the BlueDragon testing. I actually downloaded it and the installation guide. Unfortunately, you can’t have BlueDragon and ColdFusion installed on the same IIS server, so I’ll have to wait until I have time to uninstall/reinstall, etc. before I can test it. Also, they’re currently developing a .Net version of BlueDragon that will allow ColdFusion to integrate with .Net as it integrates with Java. Yay!

‘Til next time, have fun!

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

  • Dorian

    In order for the above code to work properly, you need to include cfheader




  • Jorvaulx

    In order for the code to work properly you need to include cfheader as Below




    of course there should be some error handling but I was lazy.

  • http://www.delyrical.com davidjmedlock


    I believe I tried that as well and still couldn’t get it to work…

  • davea

    I gave your code a try and it worked first time for me.
    Running CF 5. I can access the page directly view the image.

  • http://www.delyrical.com davidjmedlock

    With or without the ? I’ll have to check with the other guy I talked to and ask about his issues with HTTP in CF. I was able to get it to work in CF 5 as well, but not in that situation, even though the correct headers were set and the content type was correct and the file was there. Maybe I’m just going nuts. I’ll go back and try to put that back in the app today and see what happens…

  • Jorvaulx

    Just to make sure this is clear:
    Let say that the imagePath = “C:Inetpubwwwroothelp.gif”
    in the tag cfheader i don’t enter the whole ImagePath just the file name – “help.gif”
    but the code would look like this

    cfcontent tag would include the whole ImagePath as so:

    When I save the above code to a file “Test.cfm”, I’ve tested this and it does work when calling it from another file like this

  • Jorvaulx

    oops the cfheader should be this

    sorry about the error