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

Posted on 2003-03-03
Medium Priority
Last Modified: 2008-03-17
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)?
Question by:chrismcleod
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

by:Sashi Rachabattula
ID: 8056291
try this
if err.number=404 then

'user defined message


'normal coding

end if

LVL 15

Expert Comment

ID: 8056598

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


Author Comment

ID: 8057053
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.

Accepted Solution

bjrcreations earned 200 total points
ID: 8060023

If you have access to IIS then you can customize your 401 error page to do just about anything you want.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question