Link to home
Start Free TrialLog in
Avatar of chrismcleod
chrismcleod

asked on

Detecting 401 Errors with script (classic ASP), So as to Display Custom Error

I'm building a clients area on our website, and am trying to have a page that displays any relevant login errors that occur, of which there are 3 different script-generated errors: username/password combination not found, e-mail address not validated yet, or account not activated by admin yet. Any of these errors occuring, sends the user to the error page and an appropriate message is displayed.

The site uses basic authentication/file permissions as the login method. Obviously, if the permissions on the file do not match the supplied credentials, then the user gets a 401 error, and the script doesn't run, no scripted error messaged are generated, and the user is sat there wondering what to do.

What I want to do, is detect any 401 errors (not authorised due to wrong file/folder permissions) and send them to the same error page as my other login errors, with the error detected and a suitable message shown.

Anyone know of a way of doing this? I know part of the solution is configuring ISS to go to the error file on a 401, but how can I get the script on the error page to realise it's a 401 and display the appropriate error? Or will I have to have multiple error pages (what I'm trying to avoid, for easy maintenance)?
Avatar of Sashi Rachabattula
Sashi Rachabattula
Flag of India image

try this
<%
if err.number=404 then

'user defined message

else

'normal coding

end if

%>
Avatar of gladxml
gladxml

chrismcleod,

You can try to look at this article might help...

http://www.4guysfromrolla.com/webtech/070799-1.shtml
Avatar of chrismcleod

ASKER

gladxml - that article doesn't help me in the slightest, I'm afraid. It's about creating a drill-down application, nothing to do with what I'm needing... sorry.
ASKER CERTIFIED SOLUTION
Avatar of bjrcreations
bjrcreations

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial