How Do I Get Detailed Information About Errors in ASP or ASP.NET Pages?
When you are trying to debug your ASP or ASP.NET pages, it's important to get detailed
information about your errors. Knowing the cause of the error is often
the biggest part of solving the problem.
By default, Internet Explorer will hide most of the raw error message from you, and instead will give you a “Friendly” HTTP error message. This FAQ will show you how to disable this feature so you can see the original error that the ASP run-time threw at you. This will help tremendously in debugging your ASP applications.
When you are creating ASP or ASP.NET pages, it's likely you have seen an error like the following when you requested a page in your browser:
Figure 1 - An HTTP 500 Error as Displayed in Internet Explorer with Friendly Errors Turned On
It's also possible to get error messages like this one:
Figure 2 - An Error Message You May See when Detailed Error Messages is Disabled in IIS
I think you'll agree with me that these error messages are not very descriptive. All they tell you is that something went wrong, but it is impossible to find out what went wrong.
Good Morning, I am your Friendly HTTP Error Message for the Day
The error message from the first screen shot is what the designers of Internet Explorer call a “Friendly HTTP Error Message”. For the majority of users, this is true. This error message tells them that something went wrong, and it offers them a link back to the homepage of the site. There is no need to bother ordinary visitors with technical gobbledygook.
But for you as a developer, this message is useless. Fortunately, it's easy to get more detailed information about the error: simply turn off the Friendly HTTP Error Message feature.
To turn that feature off, open the Internet Options dialog (choose Tools | Internet Options... in Internet Explorer) and switch to the Advanced tab. You'll find the Show friendly HTTP error messages setting under the Browsing category. Make sure the item is unchecked.
Figure 3 - The Advanced Tab of the Internet Explorer Options Dialog
With the option turned off, you'll get a much more descriptive error message instead, like the next one, for example:
Figure 4 - The Full Error Message is Much More Useful.
From this error message, it's easy to see what went wrong; apparently, I forgot to create or upload the include file Adovbs.inc.
If you still don't see a detailed error message with the option in Internet Explorer turned off, but get an error like the one on the second screen shot instead, you should make changes to IIS as well. IIS offers you the option to either send detailed error messages to the client or to send a short custom message instead in case of an error. On a development server, the detailed error message is what you are really interested in. But on a production server, you don't want to send this information to the client; all you want to tell your visitor is that something went wrong. To make the change in IIS, follow these steps:
- Start the Internet Information Services management console, which you'll find the under Administrative Tools which in turn you'll find either directly on the Start Menu, or in the Windows Control Panel.
Figure 5 - The IIS Management Console
- Expand the tree in the left hand pane until you see Default Web Site. If you're configuring another Web site, or a Virtual Directory / Application, locate that one instead. This article assumes you're configuring the Default Web Site, so make sure you adjust any steps to match your situation if necessary.
- Right-click the Default Web Site in the tree at the left and choose Properties.
- Open the Home Directory tab (or Directory tab in case of a Virtual Directory) then click the Configuration button.
- On the Application Configuration dialog, switch to the Debugging tab and you'll see the following screen appear:
Figure 6 - The Application Configuration Dialog with Detailed ASP Error Messages Turned On
- On your development machine, make sure that Send detailed ASP error messages to client is turned on. As soon as you put your site in production, switch to the other option and, if you prefer, provide a custom error message.
With both these options set to provide detailed error messages, debugging your ASP pages is now a lot easier. Instead of a general "Ooops, we screwed up" message, you are now able to see the cause of the error, so it's much easier to fix your problem.
Just don't forget to change the setting in IIS to Send text error message to client when you put your site in production. Your client is really not interested in the raw details of your errors.
On a production site, you could decide to send the user to a custom error page when an error occurs. That allows you to catch the error, send an e-mail to the Web master and explain to your user in plain English what went wrong. Check out the following articles for more information about this subject:
Where to Next?
Wonder where to go next? You can post a comment on this article.
Links in this Document
|Written by||Imar Spaanjaars|
|Date Posted||03/31/2004 10:48|
|Date Last Reviewed||12/07/2006 17:23|
|Listened to when writing||Incubus - In My Room from the album: A Crow left to the murder|
Talk Back! Comment on Imar.Spaanjaars.Com
I am interested in what you have to say about this article. Feel free to post any comments, remarks or questions you may have about this article. The Talk Back feature is not meant for technical questions that are not directly related to this article. So, a post like "Hey, can you tell me how I can upload files to a MySQL database in PHP?" is likely to be removed. Also spam and unrealistic job offers will be deleted immediately.
When you post a comment, you have to provide your name and the comment. Your e-mail address is optional and you only need to provide it if you want me to contact you. It will not be displayed along with your comment. I got sick and tired of the comment spam I was receiving, so I have protected this page with a simple calculation exercise. This means that if you want to leave a comment, you'll need to complete the calculation before you hit the Post Comment button.
If you want to object to a comment made by another visitor, be sure to contact me and I'll look into it ASAP. Don't forget to mention the page link, or the Doc ID of the document.
Please correct the following errors:
Unfortunately, something went wrong and your message or comments have not been submitted successfully.
There's a fair chance things broke down because you tried to post something that looks like HTML. Things that look like HTML include (X)HTML, obviously, XML, ASP.NET markup and c# generics syntax as all of them use the < and > characters.
If that's the case, try altering your message and remove anything that looks like an angled bracket. You can replace them with [ and ] for example so you can still make it look like HTML to some extend.
If, on the other hand, you were trying to spam this web site, I am pretty glad I caught you in the act and stopped you from doing so ;-)
Also, please don't use links in your posts; I had to block them to filter out most of the junk mail I am receiving.