From a component will also be written to the ASP.net trace
okay logo confusing but it's just capturing messages that are going to ASP.net
trace what it does is it let you integrate ASP.net tracing techniques with the
system.diagnostics tracing techniques tried all the trace messages to a single
tracing output is a consolidated view of everything that is going on within
your application you can use it to do things like track the flow of execution
for an application display data critical points throughout it web.
Forms life cycle and you can discover how web forms interact with various other
components in your application to think a look at how you can put this trace
listener to work to direct trace messages from a component to an ASP.net
webpage you need to configure the webpage trace listener in the web.config file
type this trace element within the system.diagnostics that creates a listener
called web listener that's a name that I choose and it references that webpage
trace listener to this makes that listener available for this application is
external component that will provide trace information it uses the
system.diagnostics namespace and it just defines a very simple customer class
in which all of the action takes place within the constructor the constructor
receives.
A custom name string we check to see whether or not the length of that
string is equal to zero if it is then we write out a message using the
system.diagnostics.trace right line method indicated his blank and we specify
where this message is coming from whether or not the names blank we also write
out another message saying that the customers create a very simple example but
the idea here is that because this customer object is within the app code
folder it's a separate component that can send messages to ASP.net.
Typically if
we included code like this it would just output it to the components trace
listeners this is the kind of code that could appear in any.net component
including ones that aren't necessarily intended for use with an ASP.net
application what's different here is that the webpage trace listener what you
receive the trace output from such components within your ASP.net applications
and integrated together with the ASP.net trace messages the messages that are
generated from the webpage itself now to enable tracing and components that use
the system.diagnostics tracing you can use a compiler switch when you compile
the application or you can make an entry in the config file for the component
to turn that switch on automatically.
When the codes compiled so go back over
the web.config file and scroll down here and notice that I have this compiler's
element with a couple of compiler elements as child elements and all contained
within the system.co.element the idea here is that because the code for this
component the customer component is in the app code folder is automatically
compiled when ASP.net application is compiled and a reference is automatically
added to the web application.
0 comments:
Post a Comment