Solved

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

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Migration from IIS6 onto IIS7 6 53
Domino Load Balancer For 2048 Key Requirement 7 41
website does not load without www 12 73
System Analysis 5 58
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 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