Runs when a request specifies a non-existent CFML page.
<cffunction name="onMissingTemplate" returnType="boolean"> |
Method summary, Handling errors in Application.cfc in Defining the application and its event handlers in Application.cfc in the Developing ColdFusion Applications
ColdFusion passes the following parameters to the method:
Parameter |
Description |
|---|---|
targetPage |
The path from the web root to the requested CFML page. |
A Boolean value. True or no return value specifies that the event has been processed. False specifies that the event was not processed.
ColdFusion invokes this method when it encounters a file not found condition, that is, when a URL specifies a CFML page that does not exist. The onMissingTemplate function must return true to indicate that the event has been processed, or return false to indicate that the event has not been processed. If the function does not return a value, it is assumed to be true. If the function returns false, ColdFusion invokes the standard error handler. If an error occurs within the onMissingTemplate function, the error handler is not invoked. Therefore, you must use try/catch blocks in your missing template handler and, if the catch block cannot handle the error, it must set the function return value to false so the standard error handler can report the error. If the onMissingTemplate function is invoked, the onApplicationStart and onSessionStart event handlers are first invoked, if appropriate, but the onRequestStart, onRequest and onRequestEnd handlers are not invoked, and processing of the request terminates when the onMissingTemplate handler returns.All standard scopes, including the Application, Session, and Client scopes, are available in the onMissingTemplate function, if they are enabled.To include the contents of a page in the onMissingTemplate function, use the cfinclude tag. Do not any other method to include or redirect other page content, including tags and functions such as cflocation, GetPageContext().forward(), and GetPageContext().include().}}Use the {{This.welcomeFileList variable to keep this function from executing if all of the following are true:
<!--- The web.xml welcome-file-list includes index.cfm. |
When OnMissingTemplate is configued in ColdFusion Admin and when user try to access some non-existing page, OnMissingTemplate gets invoked and Tomcat returns that content. But in case of IIS, instead of showing that content IIS displays its own error page / 404 page. To fix this issue, a new property is introduced in isapi_redirect.properties, named iis_skip_custom_errors_enable. If set to true, it will skip IIS custom errors. Default value is false.
Sign in to your account