Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Debugging with Trace.WriteLine

Posted on 2006-07-14
6
Medium Priority
?
222 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 900 total points
ID: 17110484
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
ID: 17114052
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 600 total points
ID: 17117639
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 9

Author Comment

by:pallosp
ID: 17117843
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
ID: 17120180
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
ID: 17120741
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

824 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