Solved

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

Posted on 2006-10-20
4
224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SCCM vs Windows server 5 90
Finding an Azure real-time monitoring dashboard 2 92
DNS, website, godaddy 6 101
exchange 2010 turning off 3des ciphers 2 555
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…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

732 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