Solved

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

Posted on 2006-10-20
4
219 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now