Skip to main content
April 14, 2010
Question

IIS 404 redirect

  • April 14, 2010
  • 1 reply
  • 2445 views

I am running cf9 on an IIS server.  I setup a custom error page for 404 (file not found) errors.  I want to determine what page was entered into the browser before the redirect.  How do I do this?

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    April 14, 2010
    April 15, 2010

    I'm using Application.cfm and inserted the following code.

    <cfset This.welcomeFileList="index.cfm">

    <cffunction name="onMissingTemplate">
        <cfargument name="targetPage" type="string" required=true/>
        <!--- Use a try block to catch errors. --->
        <cftry>
            <!--- Log all errors. --->
            <cflog type="error" text="Missing template: #Arguments.targetPage#">
            <!--- Display an error message. --->
            <cfoutput>
                <h3>#Arguments.targetPage# could not be found.</h3>
                <p>You requested a non-existent ColdFusion page.<br />
                    Please check the URL.</p>
            </cfoutput>
            <cfreturn true />
            <!--- If an error occurs, return false and the default error
                handler will run. --->
            <cfcatch>
                <cfreturn false />
            </cfcatch>
        </cftry>
    </cffunction>

    Still no dice.

    Do I need to use Application.cfc for this to work?  Can I use both Application.cfm and Application.cfc?

    Participating Frequently
    April 15, 2010

    This is what I have in my Application.cfc file:

    <!--- Fired when user requests a CFM that doesn't exist. --->
    <cffunction name="onMissingTemplate" returntype="boolean" output="false">
      <cfargument name="thePage" type="string" required="true">
      <cflocation url="404.cfm?thepage=#urlEncodedFormat(arguments.thePage)#" addtoken="false">
    </cffunction>

    Ken Ford