Debug.WriteLine and Trace.WriteLine from class.

Discussion in 'ASP .Net' started by xxx@hotmail.com, Sep 1, 2005.

  1. Guest

    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
    , Sep 1, 2005
    #1
    1. Advertising

  2. john_teague Guest

    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
    john_teague, Sep 1, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. A.M
    Replies:
    4
    Views:
    10,848
  2. Jiho Han
    Replies:
    0
    Views:
    499
    Jiho Han
    Aug 22, 2006
  3. Replies:
    1
    Views:
    1,129
    Mike Placentra II
    Oct 14, 2007
  4. Max2006
    Replies:
    1
    Views:
    2,052
    Steven Cheng [MSFT]
    Jun 25, 2008
  5. Trace.WriteLine and Web Services

    , Sep 19, 2006, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    134
Loading...

Share This Page