How to call cfheader statuscode="404" and prevent IIS custom 404 handler from being called?

I’ve got a custom 404 handler setup in IIS that executes my 404.cfm page,
which works. The problem is that I can’t output a 404 status code from
within my code without IIS executing my 404 handler. For example, inside a
CFM page, if I call:

IIS immediately stops processing the page and executes my 404.cfm handler.
However, I typically want to output content specific to the 404 error that
I am handling inside my code, and I don’t want my generic 404.cfm handler
to be called. How can I prevent my 404 handler from being called in this
case?

My questions are:

  1. Is there a way to tell IIS to call my generic 404.cfm handler only when
    a file or directory doesn’t exist?

or

  1. If I can’t tell IIS to not execute my 404 handler, how could I pass data
    to my 404.cfm handler when I call cfheader? If I could do this, then I can
    pass custom content and my problem is solved. I determine that setting a
    request variable doesn’t make it to the handler, probably because a new
    request is being created in IIS. I also don’t want to use the session scope
    because it’s not enable it for search spiders.

I think I figured it out… I added existingResponse=“PassThrough” to my
httpErrors element in web.config file. The element looks like this:

    <httpErrors errorMode="Custom" existingResponse="PassThrough">
        <remove statusCode="404" subStatusCode="-1" />
        <error statusCode="404" prefixLanguageFilePath="" path=

“/404.cfm” responseMode=“ExecuteURL” />
On Monday, September 21, 2015 at 9:07:50 AM UTC-6, JP wrote:

I’ve got a custom 404 handler setup in IIS that executes my 404.cfm page,
which works. The problem is that I can’t output a 404 status code from
within my code without IIS executing my 404 handler. For example, inside a
CFM page, if I call:

IIS immediately stops processing the page and executes my 404.cfm handler.
However, I typically want to output content specific to the 404 error that
I am handling inside my code, and I don’t want my generic 404.cfm handler
to be called. How can I prevent my 404 handler from being called in this
case?

My questions are:

  1. Is there a way to tell IIS to call my generic 404.cfm handler only when
    a file or directory doesn’t exist?

or

  1. If I can’t tell IIS to not execute my 404 handler, how could I pass
    data to my 404.cfm handler when I call cfheader? If I could do this, then I
    can pass custom content and my problem is solved. I determine that setting
    a request variable doesn’t make it to the handler, probably because a new
    request is being created in IIS. I also don’t want to use the session scope
    because it’s not enable it for search spiders.

Alternately,
You can add this setting to the connector setting file, normally located in
c:\windows\BonCodeAJP13.settings

True

This will let you control status codes other than 200 with custom messages
from Lucee. IIS will still be able to use the standard 404-custom error
page for non-cfm related error handling, e.g. when a non-existing image
file is requested etc.

Best,
Bilal