Writing custom asp.net tracing messages Part 80

  • دعنا نشارك هذا :
ترتيب الدرس : 80
المدة : 00:10:47
التحكم :
Text version of the video

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.


All ASP .NET Text Articles

All ASP .NET Slides

All Dot Net and SQL Server Tutorials in English

All Dot Net and SQL Server Tutorials in Arabic

To write custom asp.net trace messages Trace.Write() and Trace.Warn() methods can be used. The only difference, between these 2 methods is that, the messages written using Trace.Warn() are displayed in red colour, where as the messages written using Trace.Write() are displayed in black colour. In fact, What is the difference between Trace.Write() and Trace.Warn() is a very common asp.net interview question.

Trace.IsEnabled property can be used to check if tracing is enabled. In the following code Trace.Write() method is invoked only if tracing is enabled. If you don't check, Trace.IsEnabled property prior to writing out trace messages, we don't get an exception. But if you are going to do any sort of significant work to build the trace message, then you can avoid that work by checking the IsEnabled property first.
if (Trace.IsEnabled)
Trace.Write("Debugging information");

With classic ASP, the only option for printing debugging information is Response.Write(). There are 2 problems with this
1. Actual end users also, can see the debugging information that you have written using Response.Write(). But with tracing, if pageoutput attribute is set to false, then the trace messages are written to the trace.axd file. End users cannot see the trace information.
2. All the Response.Write() statements must be removed, before the application is deployed to production. But with tracing, all you have to do is disable tracing in web.config.

سيتم تفعيل التعليقات قريبا

Sep 23, 2020 07:32:24