Solved

Sending a user back to their last visited page after an error occurs

Posted on 2006-10-20
4
223 Views
Last Modified: 2013-12-24
I have an error page that emails me whenever an error occurs within the application. What I am running into is that I have a link on the error.cfm page that points the person back to the index.cfm page. Well, the path of this link doesnt point to the correct file (I guess this has something to do with mapping).

So, I figured it probably would be better to point the user back to the last page they were on before the error occured. Only thing is, I'm not sure on how to determine the last visited page.

Code:

Application.cfm
-------------------------
<cferror type="exception" exception="ANY" mailto="mail@mydomain.com" template="public/error/error.cfm">

Error.cfm
------------------
<!--- Email Error Message --->
<cfmail from="mail@mydomain.com" to="#Error.MailTo#" subject="Error in #Error.Template#">
#Error.Template#
#Error.DateTime#
#Error.Diagnostics#
#Error.Browser#
</cfmail>


<html>
<head>
<title>Oops! An error has occurred.</title>
<link href="../../style/style.css" rel="stylesheet" type="text/css">
</head>

<body>
<p align="center"><strong>We're Sorry! An error has occurred.</strong><br>
The details of this error have been emailed to the web site administrator.<br>
Please <a href="../../index.cfm">click here</a> to return to the homepage.</p>
<p align="center"><a href="../../index.cfm">Home Page </a></p>
</body>
</html>
0
Comment
Question by:meechp123
4 Comments
 
LVL 13

Expert Comment

by:usachrisk1983
ID: 17779943
In your Application.cfm, add something like:

<cfparam name="session.thisPage" default="">
<cfparam name="session.lastPage" default=""

<cfset session.lastPage = session.thisPage>
<cfset session.thisPage = cgi.script_name>

Have your link point to #session.lastPage#.

Browse around a few pages, then hit one that causes and error and see if it comes through ok  -  I haven't tested this on my CF box, seems logical though.
0
 
LVL 4

Accepted Solution

by:
boy8964 earned 300 total points
ID: 17786323
use this:

<cfoutput>
<a href="#CGI.HTTP_REFERER#">back</a>
</cfoutput>
0
 
LVL 25

Assisted Solution

by:dgrafx
dgrafx earned 100 total points
ID: 17787582
boy8964 is correct and the trouble you're having with getting the index page can be solved by using "/index.cfm" which will be the index.cfm file in the root dir. The beginning forward slash is the root directory of the website as defined in iis.
If you want a file thats not in root then just specify file from root like "/correctdir/index.cfm".
So you could do both
<a href="#cgi.http_referer#">Back</a>
<a href="/index.cfm">Home</a>
0
 

Author Comment

by:meechp123
ID: 17788192
thanks!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to Eclipse 16 137
Use System DSN 6 90
Redundant SQL Servers Without Clustering 7 134
Internal to DMZ IIS Authentication. 3 57
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question