June 30, 2005

Info on tracing in .NET

Note: All methods of tracing mentioned here will work both in release and debug builds.

If you type the following code, you are actually invoking Page.Trace (TraceContext type) object. This object takes care of writing trace messages to trace.axd (page level tracing). For this object to work, make sure trace is enabled in web.config.


To use trace listeners, use the following code. Using this code, the trace messages will go to any listener you add to the trace listener collection. The messages will not go to trace.axd. The default listener will output the messages to OutputDebugString (normally the output window of IDE). The other options are Eventlog or text file.


You can also use conditional tracing using the following code. For this code to work, make sure a BooleanSwitch (for e.g. EnableTrace) is set to 1 in web.config under System.diagnostics section.

BooleanSwitch enableSwitch = 
     new BooleanSwitch("EnableTrace", "Some info on switch");
System.Diagnostics.Trace.WriteIf(enableSwitch.Enabled, "test");

June 14, 2005

Implementing WS-Security in .NET Web Services

This is an informative article on Implementing WS-Security in .NET Web Services using X.509 certificates. http://www.codeproject.com/webservices/WS-SecurityII.asp