views:

237

answers:

7
A: 

Breakpoints

annakata
A: 

"On Error Resume Next" --> Is obsolete.

Use Try Catch statements to cover every single piece of code that might throw an exception.

Try
' Statement which can cause an exception.
Catch x As Type
' Statements for handling the exception
Finally
'Any cleanup code. will run if exception occurs or not.
End Try
Sergio
+1  A: 

Instead of using Response.Write statements you can use ASP.NET's tracing. For outputting page-level information

'Display an informational message
Trace.Write(category, message)

'Display a warning (shown in RED)
Trace.Warn(category, message)

To enable tracing output on your ASP.NET Web pages for the entire Web application, simply set enabled to true and pageOutput to true. If you are working on a live site, you can set localOnly to true, meaning that only those hitting the site through http://localhost will see the tracing information. Add these settings in the Web.config:

<configuration>
  <system.web>
    <trace enabled="true" pageOutput="false" localOnly="false"/>
  </system.web>
</configuration>

Set the Web.config's trace to enabled as true and requestLimit to some value greater than zero. Now, visit some ASP.NET Web pages in your Web application. Now, point your browser to http://localhost/trace.axd (or whatever the directory is for your Web application)

Ref.

Mitch Wheat
I kinda suspect that @Jack is asking about Classic ASP (notwithstanding the tags assigned to the question).
Cerebrus
I just went by the tags...
Mitch Wheat
A: 

Execute the page and monitor it module by module.

Place response.write followed by response.end.

You will know where exactly the page is breaking!

The one showed in your question is the proper way of error handling in ASP pages.

Update: Looking at the other answeres it seems the question was for ASP.net? Did I get it wrong?

Shoban
+6  A: 

Why don't you just debug ? Visual Studio's debug features are excellent.

FOR ASP.NET :

Just put your breakpoint and click Debug / Attach Process select aspnet_wp.exe.

FOR ASP :

Debugging Classic ASP ( VBScript ) in Visual Studio 2008

Canavar
A: 

Eh... use the debugger?

On top of page ad On Error Resume Next After each line of code use If Err.Number <> 0 Then Response.Write Err.Description Err.Clear End if You might also Set a Debuggingvariable e.g. intDebug that you increase every x lines intDebug = intDebug + 1

Ahrrgh. My eyes! It hurts!

Tor Haugen
A: 

The problem is that this is not asp.net, but asp. I tagged it as asp.net because I didn't see a tag for asp.

Ultimate, my hacked solution was to make a huge if statement, e.g.

if 1 = 1 then ' continue happily displaying page (bunch of code until end) else Response.write "messed up variable: " & messed_up_variable

Jack BeNimble