0

When an error occurs on an ASP (Classic, VBScript) page, the resulting error message (if error responses are set to be displayed) – and also the full FREB log, if you have that turned on – shows the line number in the processed ASP file where the error occurred.

This is quite useful, because you can then look in the file, locate the error, and fix it. Or at least, you can if your ASP file is only a single file that does not include any other files.

If on the other hand your file does have any <!-- #include --> directives to include other files, things are not so useful. Since ASP/IIS includes happen before the file is processed, the line number is not the actual line number in any actual file on your disk, but the line number in a file that consists of all the included files copied into the main file at their respective locations. When you have a file that has about 30 include directives at the top and you’re then told there’s an error on line 592, you end up having absolutely no idea what physical file the line is in, and you’re left going through 30 files until you find the right one.

Unfortunately, as far as I’ve been able to tell, there’s no way to retrieve information about which file a specific line originally belonged to, so a fully useful version of an error message is not possible to achieve.

But it should at least be possible for the server to make available the source of the page it is actually processing, so that you can look at that, find line number 592 and at least know what the contents and context of the line causing the error are.

I don’t expect this can be made available in the error message output to the browser (that would be an obvious, gaping security hole), but surely it ought to be easy to include in a Failed Request Trace, which contains thousands and thousands of lines of details about absolutely everything else regarding the execution of the file. Sadly, I haven’t been able to find a way to actually do this.

Is there a way to instruct IIS to provide the compiled ASP file (as plain text) as part of a Failed Request Trace so that line numbers in error messages are actually useful?

  • When Microsoft designed FRT for IIS 7 and above, classic ASP is already a technology that's dropped from the list, so you should expect no magic there to suddenly help. You might follow examples like https://github.com/zbarutcu/asp-profiler to "joins your page and all its server-side includes into one file" and that should make the line numbers meaningful. – Lex Li Feb 03 '21 at 16:23

1 Answers1

0

There is a fairly easy way to see the combined input of the ASP file and its includes. But only to this on your dev machines, not your productions servers.

First install Server-Side-Includes, in PowerShell as admin:

Enable-WindowsOptionalFeature -Online -FeatureName IIS-ServerSideIncludes 

Now, say you have a page /index.asp with many includes. Make a copy as index.shtml in the same location and call that url in a browser.

Now view the code of the page (Ctrl+U), you should see the combined source code.

The IIS ServerSideIncludes handler, includes all the files in the include directories, but doesn't run the classic ASP interpreter.

Peter Hahndorf
  • 14,058
  • 3
  • 41
  • 58