Debug.WriteLine and Trace.WriteLine from class.

X

xxx

Hi,

I have written a class, which I instanciate from the code-behind of an
aspx page. I want to output some items to the debugger from within the
class, but Debug.WriteLine and Trace.WriteLine don't seem to do
anything. Where am I going wrong?

Thanks
 
J

john_teague

You can get to the Trace class in your class using HttpContext.Current.
HttpContext.Current.Trace.Write("Your message here");

HttpContext is basically everything from a Http request. Everything is
here. the Page class members like Request, Response, Cache, etc.. are
actually calling HttpContext members.

HttpContext.Current is a Singleton of the the current http request, so
you cannot not create a new HttpContext yourself. You must use the
Current property.

Hope this helps,
John Teague
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top