ASP.NET
Error Handling and Tracing
Host: Raj Chaudhuri – .NET Evangelist, Microsoft India
July
11, 2002
KunalS_MS: Good Afternoon to all present
KunalS_MS: Welcome to another session of MSDN India Online Expert
Chat
KunalS_MS: today's area of chat is - ASP.NET Error Handling and Tracing
KunalS_MS: and our expert host of the day is - Raj Chaudhuri
KunalS_MS: Raj is a .NET Evangelist in Microsoft India
RajC_MS: Hello, Saurabh. Thanks, Moderator.
Moderator: Well, now its over to you Raj
Moderator: You can share your queriese and doubts with Raj on ASP.NET
Error Handling and Tracing
Moderator: (Saurabh) Can you highlight tracing features in a Web Farm
scenario?
RajC_MS: I bet you attended the software Architect Summit
keynote, Saurabh.
RajC_MS: Okay, regular instrumentation in ASP.NET happens
on a single machine. The Trace class raises trace messages, which
can be picked up by a trace listener such as the DefaultListener or
the EventLogListener
RajC_MS: This is insufficient, in terms of usability,
in a web farm scenario, because ideally, you would like to view a
consolidated trace , and also be able to relate separate trace messages
in some way.
RajC_MS: For instance, let us take the case of an e-commerce
site. You might want to trace the process of placing an order. This
could happen across multiple tiers, and therefore across multiple
app domains and multiple machines.
RajC_MS: What you need is a method by which you can generate
trace messages which are a part of a larger whole. To tackle this
scenario, Microsoft is creating the Enterprise Instrumentation Framwork.
RajC_MS: The way it works is as follows:
RajC_MS: Firstly, an Enterprise defines a common schema
of "events" that they are interested in. The schema contains event
"types" (not .NET types, just a classification of events), and for
each "type", required and optional metadata is defined.
RajC_MS: Then, the Instrumentation Framework provides
a set of classes, which wrap the Trace class, and raise a trace for
each event. All relevant information indicated in the event schema
is populated.
RajC_MS: The traces are captured, as usual, to a sink.
The most common one is Event viewer.
RajC_MS: Then, a management process consolidates traces
from all machines in the scenario. The metadata is used to group all
traces for individual events.
RajC_MS: The Enterprise Instrumentation Framework is being
written in .NET, for .NET applications.
RajC_MS: It is a set of managed classes and tools.
RajC_MS: The plans are still being worked out. Last time
I spoke with the team, it would be an add-on to the Framework.
RajC_MS: In the meantime, you could use the same principles
in your project, Saurabh.
Moderator: (Rohit) How do you suggest to handle error tracing if the
same project has .asp as well as .aspx pages?
RajC_MS: Rohit, I use a custom server-side COM component
to write ASP trace messages to the Event Log, and use the EventLogTraceListener
on ASP.NET
Moderator: (Kumar) Why was the "always postback" model adopted in
ASP.NET? Just to handle events on server side?
RajC_MS: You can get around "always postback" in ASP.NET.
The default is that way to give a semi-rich experience to the end
user, and the ability to write control/event type code for the developer.
Moderator: (Ravikanth_MVP) Why I am getting different stacktrace if
I catch the exception in Application_OnError event using Server.GetLastError()
RajC_MS: Ravikanth, different from what ?
Moderator: (Ravikanth_MVP) If i catch the exception in the page it
selft..getting full stacktrace ..
Moderator: (Ravikanth_MVP) But when I catch the exception at the application_onerror
event seems not giving full stacktrace
RajC_MS: You are not "catching" the exception in Application_OnError.
HTTPServerUtility.GetLastError simply returns a copy of the last exception
thrown. By the time OnError gets called, the stack has already been
rewinded.
RajC_MS: On_Error is *called* by the framework.
Moderator: (Ravikanth_MVP) Then how to display stacktrace using Application_onError
Event if any error occurs in my webapplication?
RajC_MS: Ravikanth, are you both catching the Exception
at the page and checking it at Application_OnError ?
Moderator: (Ravikanth_MVP) Nope only checking it at Application_onerror
event
RajC_MS: One method is to use a catch-all at page level,
and throw an exception yourself.
RajC_MS: This will appear at the Error event with full
Stack Trace. I just tested this.
Moderator: (Ravikanth_MVP) Since my webproject contrains lots of aspx
files, I just want to handle exception at application_onerror.
RajC_MS: Ravikanth, there are some disadvantages, from
the tracing point of view, to this approach.
RajC_MS: To everyone, I will post the results of Ravikanth's
and my discussion on the community later.
Moderator: (GAGS) On a single server, can multiple user debug their
projects remotely? If yes please explain how.
RajC_MS: Yes, provided the projects are in isolated processes,
and certain IIS settings are done. No, you should not do it, the server
is severely strained.
RajC_MS: Thank you, everyone, for being here today.
KunalS_MS: Thank you Raj for joining us and answering our queries
RajC_MS: Thanks Kunal. It was nice being here.
KunalS_MS: and above all - thanks to all of you for joining into the
chat session