Solved

Debugging with Trace.WriteLine

Posted on 2006-07-14
6
209 Views
Last Modified: 2008-01-09
I'd like to debug a web page using Debug.WriteLine or Trace.WriteLine. Where do they output to? What should be added to web.config and the .aspx file? How should Visual Studio 2005 be configured?

My Default.aspx.cs is now

    protected void Page_Load(object sender, EventArgs e)
    {
        System.Diagnostics.Trace.Write("Hello World!");
        System.Diagnostics.Debug.Write("Hello World!");
    }

After running Default.aspx on the integrated web server nothing is seen in the Output window except the build info.
0
Comment
Question by:pallosp
  • 3
  • 2
6 Comments
 
LVL 7

Accepted Solution

by:
skvikram earned 300 total points
Comment Utility
To enable tracing for the single page
<%@ Page Trace="True" %>

It will show the trace message in browser window. within lots of other trace messages.

To enable application level tracing add the following in Web.config
<system.web>
  <trace
    enabled="true"
    requestLimit="50"
    pageOutput="false"
    traceMode="SortByTime"
    localOnly="true" />
  </system.web>

To enable application level Debugging add the following in Web.config
<system.web>
  <compilation debug="true" />
  </system.web>

0
 
LVL 9

Author Comment

by:pallosp
Comment Utility
Tre trace messages appeared, but "Hello World!" wasn't among them. The output window is still unchanged.
0
 
LVL 2

Assisted Solution

by:tempor2001
tempor2001 earned 200 total points
Comment Utility
no need to write
System.Diagnostics.Trace.Write("Hello World!");
just use
Trace.Write ("Hello World!");
(plus enable tracing as it described skvikram in previous post)
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 9

Author Comment

by:pallosp
Comment Utility
OK, I can see the text under the web page, but still nothing appears in the Output window. Setting pageOutput="true" doesn't help. Which Trace class is integrated with Visual Studio?
0
 
LVL 7

Expert Comment

by:skvikram
Comment Utility
Setting pageOutput="true" doesn't help >> Setting pageOutput="true" appends trace messages to each page of aplication

Tracing is essentially a mechanism to monitor the performance of an Application.

Application-level tracing can be performed by enabling the same in web.config or machine.config file. A special page Trace.Axd is used to view trace information collected from all the pages in the application.

ASP.NET application executes in a seperate process aspnet_wp.exe . Perfmon tool can be used to monitor the performance of application.
0
 
LVL 9

Author Comment

by:pallosp
Comment Utility
Do I think well that VS integrated trace/debug output is only supported by simple C# projects, and in ASP.NET projects I have to be satisfied with Trace.axd?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now