Reputation: 13233
The custom 404 error only gives you the page that was not found when using Request.Servervariables("QUERY_STRING")
, Well aware of this.
But how do you get the referer of that page?
Request.Servervariables("HTTP_REFERER")
in the custom 404 error page, does NOT return the referring page of the page which calls the 404 page.
The pages are in this order:
I'm trying to get the Referring page (1) from the 404 Error Page (3), not the Invalid URL (2) as you do by using the Request.Servervariables("QUERY_STRING")
Any suggestions?
Upvotes: 3
Views: 1253
Reputation: 2127
You can't easily do this on the server side, but you can on the client side, since the browser keeps history. You just have to use -2 in the history.back method.
HTML
<a id="goBack">Back</a>
JS
<script>
document.addEventListener("DOMContentLoaded", function(){
document.getElementById('goBack').addEventListener('click', () => {
history.back(-2);
});
});
</script>
Upvotes: 0