Click here to Skip to main content
15,790,645 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi Friends,
I have searched the net, forum msdn sites but not able to get exact difference in System.Diagnostics.Trace and TraceContext.

I had tried below code in my application :

Trace.Write("This is Tracing");
System.Diagnostics.Trace.TraceError("Error in first applciation");

and tracing is enable at Page level and also at Application level in web.config.

But when i see output, i get output from first line only in trace.axd.
But when i see debugger, i can see both output.


1 solution

Hi Jitendra,

While you can use System.Diagnostics.Trace for most any .NET app, System.Web.TraceContext is used only for web apps. The second, of course, relies on System.Web, so you wouldn't use it elsewhere.

Only the TraceContext is aware of the HTTP Context and, therefore, will output to the browser when page-level (or webapp-level) tracing is enabled.

Share this answer
Jitendra Zaa 8-May-10 10:55am    
Thanks Mr James..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900