Skip to main content
Participating Frequently
April 5, 2007
Question

CFCONTENt & HTTPS

  • April 5, 2007
  • 1 reply
  • 488 views
Hi, i'm having a problem migrating some CF5 code to MX7.

We have a page (code below) which runs perfetly fine on CF5 and on MX7
throws an error "Internet Explorer cannot download disp_displaydoc.cfm
from blah blah blah" We have managed to narrow the problem down to the
page being served over HTTPS as it works ok on normal HTTP.

We really need this to run over SSL and wondered if anyone had any
ideas on how we can serve these docs/pdfs etc. as before.

Thanks for your help, Ally
--------------------------------------------------------
cfsilent>
<cfscript>

function udfFileMimeType(sFilename)
{
var sMime = "";
var sExt = lcase(right(sFilename,3));

switch(sExt)
{
case "csv": { sMime = "text/comma-separated-values";break;
}
case "doc": { sMime = "application/msword";break; }
case "htm": { sMime = "text/html";break; }
case "mdb": { sMime = "application/msaccess";break; }
case "mov": { sMime = "video/quicktime";break; }
case "pdf": { sMime = "application/pdf";break; }
case "ppt": { sMime = "application/powerpoint";break; }
case "rtf": { sMime = "application/rtf";break; }
case "txt": { sMime = "text/plain";break; }
case "xls": { sMime = "application/excel";break; }
case "xml": { sMime = "application/xml";break; }
case "zip": { sMime = "application/zip";break; }

default: { sMime = "application/unknown";break; }
}

Return sMime;
}

</cfscript>

<cfparam name="URL.DIR" default="docs">

<cfset thisFile = URLDecode(URL.file)>
<cfheader name="content-disposition" value='inline;
filename="#thisFile#"'>
<CFCONTENT file="#application.PSsavepath#\#URL.dir#\#thisFile#"
TYPE="#udfFileMimeType(thisFile)#">

</cfsilent>


    This topic has been closed for replies.

    1 reply

    April 11, 2007
    We were seeing similar symptoms, which we've just resolved. Because almost every page in the application has sensitive information, in Application.cfm we had:
    <cfheader name="pragma" value="no-cache">
    <cfheader name="cache-control" value="no-cache, must-revalidate">

    Those turned out to be the culprits. Once removed, the downloads work fine.
    Our solution involved passing a url parameter to change the cache control only for specific requests.

    <cfparam name="url.allowCaching" default="false">
    <cfif url.allowCaching>
    <cfheader name="pragma" value="cache">
    <cfheader name="cache-control" value="cache">
    <cfelse>
    <cfheader name="pragma" value="no-cache">
    <cfheader name="cache-control" value="no-cache, must-revalidate">
    </cfif>

    Our problem wasn't caused by any CF upgrade or coding change on our part, but probably by some settings change on the network (proxy server, etc.). (One of those, "It used to work and now it doesn't, but we didn't change anything." bugs!)

    I hope that helps you track down your problem.
    Paul