PDA

View Full Version : Custom Errors


bruce
10-01-2003, 01:05 AM
I don't think you can do that with ASP (i may be wrong on this one). You can do such thing w/ ASP.net.

The best way to identify invalid pages is through reviewing the web statistics or log file.


[b]quote:Originally posted by homeacademy

I originally raised this question on technical support, and was told to post it here:

I am setting up a custom error system for my site, using your Control Panel IIS Manager. I would like to perform actions based on the incorrect address. How can I detect (through ASP) the URL that generated the error?

An example:
A user enters an invalid URL, say http://www.domain.com/notfound.html. A 404 error is generated, and your custom error function redirects the user to http://www.domain.com/errormanager.asp. I want errormanager.asp to log the invalid URL (http://www.domain.com/notfound.html) to a database. I cannot figure out how to programmatically detect the invalid URL from my custom error page (errormanager.asp).

Thanks in advance for the assistance.
</blockquote id="quote"></font id="quote">

homeacademy
10-01-2003, 05:14 AM
I originally raised this question on technical support, and was told to post it here:

I am setting up a custom error system for my site, using your Control Panel IIS Manager. I would like to perform actions based on the incorrect address. How can I detect (through ASP) the URL that generated the error?

An example:
A user enters an invalid URL, say http://www.domain.com/notfound.html. A 404 error is generated, and your custom error function redirects the user to http://www.domain.com/errormanager.asp. I want errormanager.asp to log the invalid URL (http://www.domain.com/notfound.html) to a database. I cannot figure out how to programmatically detect the invalid URL from my custom error page (errormanager.asp).

Thanks in advance for the assistance.

homeacademy
10-02-2003, 05:07 AM
You're wonderful!! The querystring part is just what I was looking for! [:)] Everything works as it should now. Thanks alot for the assistance.

steurm
10-02-2003, 07:07 AM
You're welcome ... [^]

--
Steurm
www.steurm.net/steurm

bruce
10-02-2003, 10:16 AM
Very cool...

Thanks Steurm

[b]quote:Originally posted by steurm

You're welcome ... [^]

--
Steurm
www.steurm.net/steurm
</blockquote id="quote"></font id="quote">

steurm
10-02-2003, 11:48 AM
yes, you can do this with regular asp.
You create an asp-page, e.g. error.asp where you will trap the errors, both asp-application errors and notfound-errors.
In your application, configure your 404-errors to be redirected to this page (error.asp)
(comment added later : and do the same for the 500.100 errors)

This is some code to detect the errors:

[quote]<%@LANGUAGE="VBSCRIPT"%>
ERRORS!
<%
response.write"[b]notfound:"&request.querystring

setobjASPError=server.GetLastError()
response.write"[b]number:"&objASPerror.number
response.write"[b]Description:"&objASPerror.Description
response.write"[b]Category:"&objASPerror.Category
response.write"[b]File:"&objASPerror.File
response.write"[b]Line:"&objASPerror.Line
response.write"[b]Column:"&objASPerror.Column
response.write"[b]source:"&objASPerror.Source
%></CODE>

this is the result, when browsing to my website to a non-existing page notfound.htm
[quote]
ERRORS!
notfound:404;http://localhost/partizan/notfound.htm
number:0
Description:
Category:
File:
Line:0
Column:-1
source:
</CODE>

This means, that the url of the page that wasn't found is given as a querystring to error.asp.

The lower part of the code in error.asp can be used to detect asp errors, like division by zero, using records when EOF is reached, ...

Hope you can start with this to configure your error handling !



--
Steurm
www.steurm.net/steurm