Tracing from Class in ASP.net application

G

Guest

Hi, I have a C# class that is being used by an ASP.net application. How can
I include the tracing from the class in the ASP.net application's trace
output (trace.axd)?
 
N

Nicholas Paldino [.NET/C# MVP]

asapjim,

You can get the current HttpContext through the static Current property
on the HttpContext. Once you have the HttpContext instance, you can use the
Trace property on the HttpContext to access the same TraceContext instance
that a Page would return.

Hope this helps.
 
G

Guest

Nicholas, thanks for the reply. I got your suggestion to work on a class
instantiated by a Page. However, my class is a Singelton that is created in
Global.asax.cs in the Application_Start event. The Tracing output from the
Singleton class doesn't go anywhere.

Nicholas Paldino said:
asapjim,

You can get the current HttpContext through the static Current property
on the HttpContext. Once you have the HttpContext instance, you can use the
Trace property on the HttpContext to access the same TraceContext instance
that a Page would return.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

asapjim said:
Hi, I have a C# class that is being used by an ASP.net application. How
can
I include the tracing from the class in the ASP.net application's trace
output (trace.axd)?
 
N

Nicholas Paldino [.NET/C# MVP]

In this case, you can not store the trace context at the class level.
You need to retrieve it in every call that the object makes.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

asapjim said:
Nicholas, thanks for the reply. I got your suggestion to work on a class
instantiated by a Page. However, my class is a Singelton that is created
in
Global.asax.cs in the Application_Start event. The Tracing output from
the
Singleton class doesn't go anywhere.

Nicholas Paldino said:
asapjim,

You can get the current HttpContext through the static Current
property
on the HttpContext. Once you have the HttpContext instance, you can use
the
Trace property on the HttpContext to access the same TraceContext
instance
that a Page would return.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

asapjim said:
Hi, I have a C# class that is being used by an ASP.net application.
How
can
I include the tracing from the class in the ASP.net application's trace
output (trace.axd)?
 

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

Top