0

I know lots of questions have been asked about this before, but this one seems to be slightly different to all the others.

When I write some poor ASP code such as:

Dim a = 7

I will get a detailed error message telling me I'm an idiot. However, if a make a runtime error such as

a = 0/0

The page will immediately finish. The loaded page shows only what was written before the error and (most importantly) there is no error message hinting at where/what the error was

How can I get runtime error messages?

What I have tried so far:

I've tried putting this into the web.config as per this question

<configuration>
<system.webServer>
    <httpErrors errorMode="Detailed" />
</system.webServer>
<system.web>
    <customErrors mode="Off"/>
    <compilation debug="true"/>
</system.web>

However that made no difference.

I also tried what was suggested in this answer:

If you can't change the IIS error settings then simply let the asp-page print the error.

At the top of the file, set On Error Resume Next to allow the asp-script to continue executing despite any errors.

Then at the possible locations where you suspect error to occur OR just at the bottom of the page; put this code.

IF Err.Number <> 0 THEN
    Response.Write "=========================================" & "<br />"
    Response.Write "Error description: " & Err.Description     & "<br />"
    Response.Write "Source: " & Err.Source                     & "<br />"
    Response.Write "LineNumber: " & Err.Line                   & "<br />"
    Response.Write "=========================================" & "<br />" 
END IF

The trouble with that solution was that the line number is empty, source just has "Microsoft VBScript runtime error" and most of the other properties of ASPError are blank. (Description has "Overflow" for divide by 0 error). So I still don't really know where the error is :(

Community
  • 1
  • 1
mdsimmo
  • 559
  • 5
  • 16
  • You're missing `scriptErrorSentToBrowser = true` in the `` section of the web.config that tells Classic ASP to send errors to the browser, see [A: display detailed error message on IIS 7.5](http://stackoverflow.com/a/29629133/692942). – user692942 Mar 23 '17 at 11:14
  • This might be a silly question, but are you sure you aren't getting an error message? I've just tried `a=0/0` and I got "Microsoft VBScript runtime error '800a0006' | Overflow /mypage.asp, | line 34". Sometimes the structure of your client side code at the point where the error is thrown means that you can't see the error message in the browser window. It's often worth using View Source if you're looking for an error description. Using `on error resume next` is generally a bad idea. – John Mar 23 '17 at 13:39
  • 1
    @John getting the `On Error Resume Next` approach to work right thought it would make more sense to point them to the actual fix for Classic ASP errors displaying in the browser. The OP does already mention that it does output anyway - *"The trouble with that solution was that the line number is empty"*, it's just not pointing them to the line where the error occurs. – user692942 Mar 23 '17 at 15:06
  • @John I get no error messages in the source code – mdsimmo Mar 23 '17 at 23:53
  • @Lankymart I skipped scriptErrorSentToBrowser because that caused the entire application to crash. Although I just re-added to find what the error message was and it caused no problems (but there's still no runtime error messages) – mdsimmo Mar 24 '17 at 00:01
  • @Lankymart that question is slightly different because in that case they were getting an (unhelpful) error message. Also, I cant alter the system settings. – mdsimmo Mar 24 '17 at 00:06
  • @mdsimmo no it's not, your contradicting yourself. You said *"I've tried putting this into the web.config"* you just focused on the wrong part. That answer deals with setting the correct values, you will to remove the `On Error Resume Next` though as this will hide the HTTP 500. While you may feel the question is different, I guarantee the solution is the same. – user692942 Mar 24 '17 at 00:52
  • 1
    @mdsimmo *"I skipped scriptErrorSentToBrowser"*? That is the most important part without it Classic ASP will not send any errors to the browser and you will just end up with a generic `"An error occurred on the server when processing the URL."` etc. Remember if running in IE *(which I wouldn't recommend)* make sure `Show Friendly HTTP Errors` is unticked in the Advanced tab of the Internet Explorer Settings. Plus I have no idea what you mean, when you say *"caused the entire application to crash"*?? Your going to have to expand on that a bit... – user692942 Mar 24 '17 at 01:02
  • 1
    @Lankyman By crash, I mean this: http://stackoverflow.com/questions/25315788/http-1-1-new-application-failed. Also, you are completely correct in that this is a duplicate. I had some configuration set (I don't know where) that the directory I was working in would hide errors. I moved directory and now I am getting the standard "An error occurred...". Thanks for all you help – mdsimmo Mar 24 '17 at 02:51
  • 1
    @mdsimmo that specific error is usually related to either an incorrect setting or the Application Pool needs restarting to bring it in line with changes to the website. – user692942 Mar 24 '17 at 12:43

0 Answers0