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:
<cfheader statuscode="404" statusText="not found">
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
2. 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.