Library code snippets
Debug ASP.NET pages using Tracing
In Classic ASP one might debug some code using VB Script:
Response.Write strSQL
Response.End()
and the comment/uncomment the code accordingly. This was a bit of a pain during the development process. In ASP.NET, one can use the Trace feature which simplifies matters somewhat. Page-level tracing can be set in the Page directive on the ASPX page:
<%@ Page Language="c#" Trace="true"%>
and in the code one could use:
string strSQL="select * from " + Table + " " + WhereClause + " order by " + OrderingColumn;
Trace.Write("SQL",strSQL);
When the page is run in the browser, you'll see:
So, you'd be able to see the SQL that is executed. By using Trace.Warn instead of Trace.Write, the line would be highlighted in Red. When the application is deployed, you'd simply disable tracing by setting the Trace attribute to false. If you have many pages that you wish to trace, then it may be more viable to set the tracing in your web.config file:
<system.web>
<trace enabled="true" requestLimit="20" pageOutput="true" traceMode="SortByCategory" localOnly="true" />
</system.web>
So, you can easily enable/disable tracing as required.
Related articles
Related discussion
-
Gizmox Announces release of Visual WebGui SDK version 6.2.2
by Visual WebGui (0 replies)
-
Error 4 Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).
by lbargers (3 replies)
-
How to receive data in web server sending from GPRS modem
by AshokSingh (1 replies)
-
Working with frames in c# .net
by pulak2008 (0 replies)
-
Time Out Problem
by lorrainepetty (1 replies)
Related podcasts
-
CodeCast Episode 4: State of .NET, IE8, ASP.NET MVC, and O'Reilly Media
CodeCast Episode 4: State of .NET, IE8, ASP.NET MVC, and O'Reilly MediaHosts Ken Levy and Markus Egger discuss the new State of .NET events, IE8, ASP.NET MVC, followed by an interview from PDC with two editors from O'Reilly Media. More on ASP.NET MVC can be found at http://asp.net/mvc. Interview...
Related jobs
-
Microsoft .Net Architect
in AMSTERDAM (€50K-€90K per annum) -
Microsoft Dynamics CRM Technical Consultant
in Netherlands (€50K-€90K per annum) -
.net developer
in Rijswijk (€2K-€4K per annum)
Events coming up
-
Dec
3
An afternoon of SQL Server Data Services and ASP.NET Dynamic Data
Bradford, United Kingdom
This event is in association with Black Marble. In the morning Black Marble will be presenting on Microsoft "Oslo": The Future of Enterprise Applications. To find out more about this please follow the link on the right.
This thread is for discussions of Debug ASP.NET pages using Tracing.