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
Solved

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

Posted on 2006-10-20
4
222 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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
iis reverse proxy virtual directory 8 205
ColdFusion Rereplace 3 81
System Analysis 5 61
web & database SERVERS -- PHYSICAL & VM ? 5 72
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…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

861 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