Best Way To Debug ASP Pages

Discussion in 'ASP General' started by Matthew Louden, Sep 27, 2003.

  1. I want to know what's the best way to debug ASP pages? Now, I just put the
    following code when I got run-time error, but sounds like not efficient.
    Please advice! Thanks!

    Response.Write "Here"
    Response.End
    Matthew Louden, Sep 27, 2003
    #1
    1. Advertising

  2. Matthew Louden

    PB4FUN Guest

    1. Visual Interdev
    Real debugging like in Visual Basic : line by line,
    asking values of variables, set a watch, change variables in runtime
    etc.
    2. 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

    If Err.Number <> 0 Then
    Response.Write intDebug
    response.Write "<BR>"
    Response.Write Err.Description
    Err.Clear
    End if

    But first option (Visual Interdev) is the best IF you get it working.

    Meindert, MCP

    > I want to know what's the best way to debug ASP pages? Now, I just put the
    > following code when I got run-time error, but sounds like not efficient.
    > Please advice! Thanks!
    >
    > Response.Write "Here"
    > Response.End
    >
    >
    >
    PB4FUN, Sep 27, 2003
    #2
    1. Advertising

  3. Matthew Louden

    Chris Barber Guest

    See the following for details of how to set it up (Visual Interdev
    Debugging).

    http://www.windowswebsolutions.com/Articles/Index.cfm?ArticleID=20431

    http://www.microsoft.com/mind/0299/beyond/beyond0299.asp

    Chris.

    "PB4FUN" <> wrote in message
    news:...
    1. Visual Interdev
    Real debugging like in Visual Basic : line by line,
    asking values of variables, set a watch, change variables in runtime
    etc.
    2. 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

    If Err.Number <> 0 Then
    Response.Write intDebug
    response.Write "<BR>"
    Response.Write Err.Description
    Err.Clear
    End if

    But first option (Visual Interdev) is the best IF you get it working.

    Meindert, MCP

    > I want to know what's the best way to debug ASP pages? Now, I just put the
    > following code when I got run-time error, but sounds like not efficient.
    > Please advice! Thanks!
    >
    > Response.Write "Here"
    > Response.End
    >
    >
    >
    Chris Barber, Sep 28, 2003
    #3
  4. Matthew Louden

    C. Olive Guest

    "PB4FUN" <> wrote in message news:<>...
    > 1. Visual Interdev
    > Real debugging like in Visual Basic : line by line,
    > asking values of variables, set a watch, change variables in runtime
    > etc.
    > 2. 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
    >
    > If Err.Number <> 0 Then
    > Response.Write intDebug
    > response.Write "<BR>"
    > Response.Write Err.Description
    > Err.Clear
    > End if
    >
    > But first option (Visual Interdev) is the best IF you get it working.
    >
    > Meindert, MCP
    >
    > > I want to know what's the best way to debug ASP pages? Now, I just put the
    > > following code when I got run-time error, but sounds like not efficient.
    > > Please advice! Thanks!
    > >
    > > Response.Write "Here"
    > > Response.End
    > >
    > >
    > >


    Another useful method I've used on any server, not just IIS, is
    writing HTML comments to the client. Then use "View Source" to see
    the comments sprinkled along with the actual visible markup. Under
    IIS, an ASP subroutine like this works great:

    Sub Debug( strMsg )

    Response.Write "<!-- " & strMsg & " -->" & vbCRLF

    End Sub

    ....then in code...

    While Not RS.EOF
    Response.Write "<td>" & RS.Name & "</td>"
    Debug RS.Address 'Not sure what to do with this yet
    Debug RS.City 'Is this coming out right?
    Debug RS.State 'etc.
    Loop

    Chris
    -----
    Chris Olive
    chris [I'm at] technologEase [dot] com
    http://www.technologEase.com
    (pronounced "technologies")
    C. Olive, Oct 1, 2003
    #4
  5. Matthew Louden

    J. Spraul Guest

    IIS v5+ has an exponential increase in error-handling
    support. I guess if you're talking about debugging
    during development, then this may not be as much
    of an interest to you, but you can read more here...

    http://www.devarticles.com/art/1/382

    If you don't have Visual Interdev + IIS installed on
    your development machine then you won't be able to
    step through your ASP (and some people still can't
    even when they do have both installed - it's a
    royal pain to get working). Here's that info...

    http://support.microsoft.com/support/kb/articles/Q244/2/72.ASP

    If you want, you can use a subroutine to make it
    a little easier (it's been a while since I've done
    this, but I think it will work). Just put the main
    logic of your code in a subroutine, like this...

    SUB Main()
    'do your stuff here...

    END SUB

    ' this is the only non-subroutined ASP on the page...
    ON ERROR RESUME NEXT
    CALL Main
    IF Err.Number THEN Response.Write Err.Description


    You can switch to Server.GetLastError() if you're
    using IIS 5/ASP 3 so you can get more info, like
    the line that the error occurred on. If you didn't
    mind using this same approach in production, you
    could stick the part the calls Main in an include
    and have a SUB Main in every ASP file which pulls
    in the include... then you can switch between
    debugging & "notify me when something wrong happens
    because it should work" modes. Here is some info
    specifically on the GetLastError/ASPError stuff...

    http://www.devguru.com/Technologies/asp/quickref/asperror.html

    ~jed

    "Matthew Louden" <> wrote in message news:<>...
    > I want to know what's the best way to debug ASP pages? Now, I just put the
    > following code when I got run-time error, but sounds like not efficient.
    > Please advice! Thanks!
    >
    > Response.Write "Here"
    > Response.End
    J. Spraul, Oct 1, 2003
    #5
  6. Matthew Louden

    Bullschmidt Guest

    Of course Response.Write's are a good way to do some debugging.

    For example in a login page where the user's access level is assigned to
    a session variable one could do something like the following:
    Response.Write objRST("UserName") & "<br>"
    Response.Write objRST("UserPassword") & "<br>"
    Response.Write objRST("UserAccess") & "<br>"
    Response.Flush
    Response.End

    The second of the last line above is often required if buffering is set
    on (Response.Buffer = True) which it perhaps usually would be.
    The last line above is optional for if you need to stop the code from
    running after that point (i.e. to avoid a page redirect or something).

    Debugging your ASP Scripts by Abd Shomad - 2/10/1999
    http://www.4guysfromrolla.com/webtech/021099-1.shtml

    Best regards,
    J. Paul Schmidt, Freelance ASP Web Developer
    http://www.Bullschmidt.com
    ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Bullschmidt, Oct 2, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt

    Best way to debug XSL?

    Matt, Oct 12, 2004, in forum: XML
    Replies:
    2
    Views:
    493
    Arto Viitanen
    Oct 15, 2004
  2. The best way to debug an error

    , Feb 10, 2009, in forum: C Programming
    Replies:
    5
    Views:
    303
  3. Replies:
    2
    Views:
    115
    Griff
    Jun 1, 2005
  4. mike
    Replies:
    1
    Views:
    111
    Mr Beaton
    Sep 15, 2005
  5. J. D.
    Replies:
    4
    Views:
    164
    Florian Gross
    Dec 7, 2004
Loading...

Share This Page