Print Page | Close Window

Custom 404

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=25209
Printed Date: 29 March 2026 at 12:51am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Custom 404
Posted By: dwhite02
Subject: Custom 404
Date Posted: 26 January 2008 at 1:03am
I'm working on a custom 404 which provides suggested links based on the page being sought.
 
My question is in 2 parts:
 
1. When I try and set an ASP page to be a custom 404, the html appears as text on the rendered page. Why is this and can I fix this. Is it possible to have an ASP page as a custom 404. Web Server is IIS6. I wanted to suggest links (sourced from a DB) based on the page address causing the 404 <% =( "http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("URL") )%>.
 
2. Whilst working around the problem mentioned above, I have made a .htm page the custom 404 and am using it to manually link to the ASP page to list possible suggested links (sourced from a DB) based on the referer <% = request.ServerVariables("HTTP_REFERER") %>. This introduces another click. I have tried used a meta tag refresh and seperately a javascript redirect to get the .htm page to take you to the ASP page, but the referer is not included. Is there a way around this. Will a response.redirect achieve this?
 
Hope someone can help with either/both problem(s).
 
Cheers.
 



Replies:
Posted By: michael
Date Posted: 26 January 2008 at 3:26pm
Why shouldn't you be able to use an asp page? Simply change the custom error page in IIS. Doing that all the time.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: WebWiz-Bruce
Date Posted: 26 January 2008 at 6:08pm
You can use ASP files as 404 pages, you need to select the type as a URL then point it to your 404 ASP page, eg:-

/HTTPerrors/404page.asp

We use one on our main www.webwiz.net site (have a go if you like).

Beceuase we had a big site change recently the 404 ASP page gets the 404 URL and then if the page has moved redirects based on that URL, if it's not a moved page it shows a sheach form.

You could use the same thing to get the URL for your search, the code below is what we use to get the URL that was a 404:-

'Get the 404 page
str404Page = Request.ServerVariables("Query_String")

'Chop out the crap we don't want
str404Page = LCase(Mid(str404Page, InStr(str404Page, ":80/") + 3, Len(str404Page)))




-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net