title: Problems handling 404 errors in ColdFusion 10 on Win2k8 R2 x64?
body: <p>I'm having difficulties handling 404 errors correctly in ColdFusion 10 on Windows 2008 R2 x64 using a custom error handler (Execute URL) in IIS. I've done this in previous versions of CF with no problems. In IIS, under the web site features, I open "Error Pages" and set it to execute "/404.cfm" for all 404 errors.</p>
  
  <p>The problem I'm having is that the output of the 404.cfm page is not completely being sent back to the browser and the page doesn't load correctly. Sometimes I get nothing back, other times I get 1K, other times I get a little bit more. It's very inconsistent.</p>
  
  <p>Along with setting the 404.cfm handler in IIS, I am also calling it in the onMissingTemplate() method inside Application.cfm:</p>
  
  <pre><code>&lt;cffunction name="onMissingTemplate"
      returnType="boolean"
      output="true"&gt;
  
      &lt;cfargument name="thePage" type="string" required="true"&gt;
  
      &lt;cftry&gt;
  
          &lt;cfmodule template="../../../404.cfm" thePage="#Arguments.thePage#"&gt;
  
          &lt;cfcatch&gt;
              &lt;cfoutput&gt;&lt;p&gt;An error occurred&lt;/p&gt;&lt;/cfoutput&gt;
          &lt;/cfcatch&gt;
  
      &lt;/cftry&gt;
  
      &lt;cfreturn true /&gt;
  &lt;/cffunction&gt;
  </code></pre>
  
  <p>Inside my <strong>404.cfm</strong> error handler, I'm calling:</p>
  
  <pre><code>&lt;cfheader statuscode="404" statustext="Not Found"&gt;
  </code></pre>
  
  <p>... and then I output a bunch of stuff.</p>
  
  <p>When I remove the call to cfheader in 404.cfm, the error handler loads correctly [for ColdFusion requests]. That's because nothing is going through IIS - instead, it's simply going through the onMissingTemplate() method in ColdFusion. However, the response header gives me a 200 status code, which is a problem! It needs to be a 404 status code for obvious reasons.</p>
  
  <p>When I include the cfheader call, <strong>OR</strong> when a non-ColdFusion page is being requested (IIS will generate the 404 status code), the output of my 404.cfm handler is not completely returned to the browser. I think has something to do with IIS getting its hands on the action.</p>
  
  <p>I did report this in the CF bug database, but I'm wondering if there's something I'm doing wrong. The bug is here: <a href="https://bugbase.adobe.com/index.cfm?event=bug&amp;id=3488063" rel="nofollow">https://bugbase.adobe.com/index.cfm?event=bug&amp;id=3488063</a></p>