Helping people with computers... one answer at a time.

I have a few pages on my web server that have been created using Cold Fusion, and thus have the ".cfm" file extension. When I view those pages in my browser, they seem to work just fine. However I've been getting reports of some people seeing raw HTML when the view those pages, and not the formatted pages I'd expect. What's up with that?

Well, the good news is that's it's most likely an easy, if obscure, fix that you, or your webmaster, needs to do.

The "bad" news, if you want to call it that, is this: the browsers that are showing you what you expect? They're technically wrong.

What most people don't realize is that the filename extension, the ".html", ".htm", ".cfm", ".php" and so on, is pretty much ignored by your browser. Sure, it's part of the filename, and it gets sent off to the web server when you view a web page, but that's really about it.

Your browser really doesn't care or pay much attention to what the extension is. †

The web server on the other hand, cares deeply.

The filename extension is used by the web server to know how to process the request. By default, ".html" files, for example, are simply copied back down to your browser, pretty much as is. ".shtml" files are pre-processed, and then the results copied down. ".cfm" files are run through the Cold Fusion processor, and the output is sent to your browser. ".php" files are run through the PHP interpreter, and the output is sent to your browser.

But that's only part of the story. When the server sends something down to your browser, it also includes information that tells the browser what it is it's sending. For example your ".cfm" file may fire up the Cold Fusion processor, but the results that get sent back down to your browser is just plain old HTML. That makes it easy on your browser, because regardless what wonderful technology was used on the server - Cold Fusion, PHP, or something we haven't thought of yet - the server just tells the browser "this is HTML", and the browser knows what to do with it.

The problem arises with unknown file types. If you have on your server a file called "example.leo", and you request it in your browser ... well, the browser doesn't care that it's a ".leo" file, it just asks the server for it. The server, on the other hand, has no idea what a ".leo" file is, so it makes an assumption: this must be plain text. And that's what it tells the browser: "this is plain text". The browser should just display the contents of the file, without formatting, much like if you had opened the file locally in notepad.

Now, in your case, it looks like your server knows what to do with ".cfm" file requests: send them off to the Cold Fusion processor. But it looks like it has not been configured to know that the output of Cold Fusion is HTML (or alternately, Cold Fusion has not been configured to indicate that its output is HTML). Your ".cfm" pages are probably coming out with the indication that they are text, not HTML. (For the more technically inclined, the HTTP headers returned include "Content-Type: text/plain" instead of "Content-Type: text/html".)

But wait! It gets more confusing!

Several browsers, I assume to be "more helpful", will attempt to display pages marked as plain text as HTML anyway. (Presumably if it "looks like" HTML to them.) So this means that even though your ".cfm" pages are incorrectly indicating that their output is plain text, some browsers will incorrectly treat it as HTML.

Two wrongs making a right, as it were.

Other browsers that actually pay attention to the content type, display the output as plain text, which means displaying the raw HTML to their users.

So that was a very long explanation that boils down to this: the server hosting your site is not configured to correctly indicate that ".cfm" output is HTML. Exactly how to correct that will vary based on the type of server you're running, and may possibly involve settings within Cold Fusion itself.

† - ok, some browsers may pay attention to the filename extension as a hint for what to do with the file. But technically, they're probably not supposed to.

Article C2385 - July 14, 2005 « »

Share this article with your friends:

Share this article on Facebook Tweet this article Email a link to this article
Leo Leo A. Notenboom has been playing with computers since he was required to take a programming class in 1976. An 18 year career as a programmer at Microsoft soon followed. After "retiring" in 2001, Leo started Ask Leo! in 2003 as a place for answers to common computer and technical questions. More about Leo.

Not what you needed?

10 Comments
Susan
October 17, 2005 7:44 AM

Hi,

When I browse to a site which has .cfm files they are not being displayed as HTML but this is only happening on one particular PC, the others that we use are able to display the pages correctly, or rather as we would expect to see them. Is there anything that I can do on the local PC to correct this?

They were displaying as HTML before, but are no longer on this specific PC.

Any help would be appreciated.

Thanks
Susan

gdfs
April 18, 2006 9:44 PM

I am having hte same problem as susan, when I click on a cfm link I get a prompt to save or open; saving saves the file and open does nothing.

Holly
June 1, 2006 3:28 PM

My computer just started being weird two days ago. I deleted cookies and temp files from my internet explorer settings, and now i cant see these CFM files. Help?

bruno
November 27, 2006 8:04 AM

I have read the article. It explains what may cause the problem, but does not offer a solution. I cannot view CFM pages. Same problem as Susan, GDF and Holly. Please help.

Leo Notenboom
November 27, 2006 8:46 AM

Reread the last paragraph of the article. It's not something YOU can correct, UNLESS you are the owner of the server you're try to access.

Rich
January 4, 2007 6:13 PM

I am confused. I access a doc system at work fine from my pc as do others from their mobile devices. However, I just got a smart phone and when I attempt to access a .pdf, say, I get a message stating that "this device does not support this type of file" and asking if I want to save this ".cfm" (not .pdf) file to my memory card. You seem to be saying that the problem is on the webserver side, however, I can view and download the .pdf, .doc, .xls, etc... with other browsers from other machines. There would seem to be some sort of difference between browsers/user/viewer configurations as opposed to the webserver/page itself. I accept that how the page is constucted creates this problem (note that I have to trouble downloading .pdf files from the irs website) however, it is also clear that other devices/browsers have no trouble getting the correct files.

Rich
May 22, 2008 1:39 PM

There is nothing you can do on your end as Leo mentioned. RR is updating their main page as of
5/22/08 and they are aware of this. CFM files are once again.,.....ON THE SERVER. Not a problem with your computer.

Michael
October 16, 2008 3:27 PM

i am having the 'save\print' prompt, i am the owner of this server (my dev. server). what can i do?

Joe
February 26, 2010 6:07 PM

I just had to reload windows, and had not reinstalled Adobe reader and I had a problem reading the .cfm files. After I installed Reader - it worked fine.

El Laurens
May 6, 2011 8:16 AM

For those who may stumble across this in the search to get a .CFM file to open in their browser.
Although my browser(s, Firefox and IE) could "see" the file once I added the file type to my PC (XP) neither could actually successfully open things until I installed Adobe Reader. Thanks Joe for your comment, got me up and running.

Comments on this entry are closed.

If you have a question, start by using the search box up at the top of the page - there's a very good chance that your question has already been answered on Ask Leo!.

If you don't find your answer, head out to http://askleo.com/ask to ask your question.