We help IT Professionals succeed at work.

showing asp class errors in asp.net website

Starr Duskk
Starr Duskk asked
on
I have a web server setup for asp.net website 4.5 framework.
Someone is wanting to run an asp classic web page on the site. It gets 500 internal server errors under certain circumstances. I'd like to be able to see the actual error message.

I put debug=true in the asp.net web.config which did not help.
so what do I need to setup on the server for this asp classic page to show an actual error message.
thank you.
Comment
Watch Question

Big MontyWeb Ninja at large
Commented:
There a setting in IIS to send errors to the browser, see the article below for detailed instructions

http://www.chestysoft.com/asp-error-messages.asp
Developer & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
The first thing you need to make sure is classic asp is turned on.  Wayne has this detailed http://www.experts-exchange.com/articles/3730/Setting-up-IIS7-5-in-Windows-7-to-run-Classic-ASP-Web-Sites.html as does the iis.net site http://www.iis.net/learn/application-frameworks/running-classic-asp-applications-on-iis-7-and-iis-8/classic-asp-not-installed-by-default-on-iis.  

Assuming that is done, you need to at least turn on errors.  In IIS, go to the ASP section and "send errors to browser" should be set to true.  Debugging set to true does not do this. http://www.iis.net/learn/application-frameworks/running-classic-asp-applications-on-iis-7-and-iis-8/classic-asp-script-error-messages-no-longer-shown-in-web-browser-by-default

However, sending these detailed errors to the browser should only be done while developing and not in production.  An easy alternative is to catch the errors.

At the top of the page below
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% On Error Resume Next %>

Open in new window

Then at the bottom of the page
<%
If Err.Number <> 0 Then
   Response.Write (Err.Number&" "&Err.Description)
end if
%>

Open in new window

Again, you only want these errors to show while not in production.

What he can do is
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include virtual="/top_level_includes_folder/error_top.asp"-->

Open in new window

Then at the bottom of the page
<!--#include virtual="/top_level_includes_folder/error_bottom.asp"-->

Open in new window


error_top.asp
dim site_status
site_status="testing" ' or production
if site_status ="testing" then
     On Error Resume Next ' only trap errors in testing
end if

Open in new window

error_bottom.asp
if site_status ="testing" then
   If Err.Number <> 0 Then
          Response.Write ("<hr>"&Err.Number&" "&Err.Description)
          response.end ' make sure nothing else processes
     else
        Response.write "************<br>WARNING: TESTING MODE<br>************"
   end if
if site_status ="testing" then

Open in new window

This way, when the site is in testing, he only needs to upload error_top.asp once then when the site is in production change site_status="testing" to site_status="production" ' or anything but testing.  And make sure those include files are on every page.  This method is probably the safest way to go.
Starr DuskkASP.NET VB.NET Developer

Author

Commented:
thanks!

Commented:
I recently implemented Scott Fell's error catching solution because I had a similar situation to what BobCSD described in his question,  This solution worked very well for me and saved me tons of debugging time and frustration. Many thanks to Scott and Experts Exchange!
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Commented:
tgritter, thank you very much for the update!!