3

My web.config looks like this:

<configuration>
    <system.webServer>
        <httpErrors>
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" prefixLanguageFilePath="" path="/error-404.cfm" responseMode="ExecuteURL" />
        </httpErrors>
    </system.webServer>
</configuration>

If I navigate to page that doesn't exist, it correctly loads up the 404 page, but chrome's network log shows a 200 response. How can I make sure there's a 404 response? Or does it matter?

Miguel-F
  • 13,450
  • 6
  • 38
  • 63
Patrick Schomburg
  • 2,494
  • 1
  • 18
  • 46
  • 6
    Yes it does matter. You want to send a 404 header back to the browser. You can set that header in your ColdFusion template `/error-404.cfm`. Just add this to that code `` – Miguel-F Feb 05 '19 at 21:47
  • Ahh okay. See I was using `` in `onMissingTemplate`, and since it just redirected the user, the 404 code was never called. – Patrick Schomburg Feb 06 '19 at 15:57
  • For anyone running into a similar issue, this worked for me; put ` ` in the application.cfc file, then putting `` at the top of error-404.cfm. – Patrick Schomburg Feb 06 '19 at 15:59
  • Patrick you should add your solution as an answer to the question. It is okay to answer your own question and it will make it more visible to others reaching this page. – Miguel-F Feb 06 '19 at 16:38

1 Answers1

3

For anyone running into a similar issue, this worked for me; put

<cffunction name="onMissingTemplate"> <cfinclude template="error-404.cfm" > </cffunction>

in the application.cfc file, then put

<cfheader statuscode="404" statustext="Not Found"> at the top of error-404.cfm

Patrick Schomburg
  • 2,494
  • 1
  • 18
  • 46