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. Advertisements

  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. Advertisements

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. Rukmal Fernando
    Replies:
    4
    Views:
    1,067
    Richard Grimes [MVP]
    Oct 27, 2003
  2. A.M
    Replies:
    4
    Views:
    11,208
  3. Matthias S.
    Replies:
    1
    Views:
    836
    Daniel Fisher\(lennybacon\)
    Nov 30, 2005
  4. Jiho Han
    Replies:
    0
    Views:
    712
    Jiho Han
    Aug 22, 2006
  5. =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=

    Adding my messages to the trace.axd trace?

    =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=, Apr 6, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    773
    =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=
    Apr 6, 2007
  6. Replies:
    1
    Views:
    1,247
    Mike Placentra II
    Oct 14, 2007
  7. Max2006
    Replies:
    1
    Views:
    2,835
    Steven Cheng [MSFT]
    Jun 25, 2008
  8. Trace.WriteLine and Web Services

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