Detecting 401 Errors with script (classic ASP), So as to Display Custom Error
Posted on 2003-03-03
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)?