Saturday, December 15, 2007

Tracing

In Active server pages to debug we need to use Response.Write statements to display any information to the screen.
With the help of Visual Studio.net any diagnostic information can be displayed using Tracing.
Tracing can be enabled for Page Level or application level.
  • Page Level Tracing


  • <%@ Page Language="vb" AutoEventWireup="false" Trace="true" Codebehind="Practise.aspx.vb" Inherits="Example.Practise"%>

    Or in the code-behind using the Trace object:

    Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) _
    Handles MyBase.Load
    Trace.IsEnabled = True
    End Sub

  • Application-Level Activation


  • In web.config change the code as



    Other way is using Global.asax in Application_BeginRequest method:

    If (Context.Request.QueryString("trace") = "true") Then
    Context.Trace.IsEnabled = True
    End If

    The trace can contains up to 10 sections, many of which only appear if they contain data.
    The sections are: Request Details, Trace Information, Control Tree, Session State, Application State,
    Cookies Collection, Headers Collection, Form Collection, QueryString Collection, and Server Variables.

    1 comment:

    Unknown said...

    nice collection keep it up