Highlighted

cfcontent and "cannot be displayed because it contains errors"

New Here ,
Jan 09, 2018

Copy link to clipboard

Copied

I'm having an issue delivering an image using content.

I'm getting the following error when using cfcontent:  "... cannot be displayed because it contains errors".

Here is a sample of the code:

<cfcontent reset="true" file="C:\Storage\Sites\localhost\stars.jpg" deleteFile="false" type="image/jpeg" />

<cfabort>

Here's the odd thing ... If I access the coldfusion script directly; ie, http://localhost/test.cfm  it works just fine.

But if i'm doing any type of url rewriting through IIIS web.config it doesn't work; ie, http://localhost/test   (which through url rewrite would map to test.cfm). 

Any ideas anybody?

Views

160

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

cfcontent and "cannot be displayed because it contains errors"

New Here ,
Jan 09, 2018

Copy link to clipboard

Copied

I'm having an issue delivering an image using content.

I'm getting the following error when using cfcontent:  "... cannot be displayed because it contains errors".

Here is a sample of the code:

<cfcontent reset="true" file="C:\Storage\Sites\localhost\stars.jpg" deleteFile="false" type="image/jpeg" />

<cfabort>

Here's the odd thing ... If I access the coldfusion script directly; ie, http://localhost/test.cfm  it works just fine.

But if i'm doing any type of url rewriting through IIIS web.config it doesn't work; ie, http://localhost/test   (which through url rewrite would map to test.cfm). 

Any ideas anybody?

Views

161

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 09, 2018 0
New Here ,
Jan 09, 2018

Copy link to clipboard

Copied

Oh, and i'm using coldfusion 10.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 09, 2018 0
Engaged ,
Jan 09, 2018

Copy link to clipboard

Copied

If it works without the rewrite, I would first look at what might be wrong with your rewrite rules, not the CFML code itself, especially since the link to the file is absolute.  Can you post the entire error?

I am not sure quite what you are trying to accomplish since you are using cfcontent to serve an image and then aborting, whereas a browser is perfectly capable of doing this on its own.  Perhaps you can provide further details.  The reset attribute is also ignored since you are specifying the file attribute.  This would not have a negative effect, just letting you know.

- Nic

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 09, 2018 0
trinthlo LATEST
New Here ,
Jan 09, 2018

Copy link to clipboard

Copied

In my examples, I was trying to simplify and troubleshoot things, but ultimately my code has all requests going through index.cfm as it's acting as a controller.  Here is my web.config

                <rule name="general-1" stopProcessing="true">

                    <match url="^(.*)$" />

                    <conditions logicalGrouping="MatchAny" trackAllCaptures="false">

                        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />

                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />

<add input="{REQUEST_URI}" pattern="CFFileServlet/(.*)" ignoreCase="false" />

                    </conditions>

                    <action type="None" />

                </rule>

                <rule name="general-2" stopProcessing="true">

                    <match url="^(.*)$" />

                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />

                    <action type="Rewrite" url="index.cfm?path={R:1}&{QUERY_STRING}" appendQueryString="false" />

                </rule>

If I change    index.cfm?path={R:1}&{QUERY_STRING}   to just index.cfm   the cfcontent tag works just fine, but unfortunately I need the rest of it passed through.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 09, 2018 0