Team Fly |
Page 656
If you want your custom message to really stand out in the trace listing, substitute Trace.Warn for Trace.Write. Tracing can be a special tool when debugging because of the wealth of information it provides, and because it shows you a complete list of all the steps that took place during execution, their order, and their duration.
Tracing tells you these primary facts:
How long each step takes in milliseconds (you can quickly see if there are any significant delays, or use this information to optimize your application)
Which processes executed
Any error messages, and specific details about these errors
Custom trace messages you insert, along with variable values if you wish to add them (illustrated above)
Details about variables used in the project
Specifications about the containers and controls on each page
Specifications about when requests happened
When you request a trace you see six major divisions, but the Trace Information section is most often the most useful information. The Request Details section simply identifies the HTTP request type and other data about the request such as the type of character encoding (usually Unicode), when the request was made, and so on. The Control Tree lists server controls that may be on your page, and also lists child controls. If you're tracing an ordinary ASP.NET page, you would see a Cookies Collection section, but this isn't displayed for a mobile application. Instead, you see a Session State section that displays the Session ID. The Headers Collection zone lists the HTTP headers that your server sent to the client device. In ordinary ASP.NET applications, this section also includes cookie information. Finally, the Server Variables section describes your server in considerable detail, identifies quite a bit about the state of your server—its URL, connection type, and so on.
You always want to avoid frightening your users with lengthy, technical error messages such as Object Not Found or Stack Collapse. They'll think their PDA is broken, or their phone is about to explode. Never underestimate the confusion and fear that the average person experiences after punching some buttons on a high-tech device. If anything unusual happens, many of them think they must have accidentally entered the activation code.
In ordinary Windows applications, you can intercept error messages and, instead of letting users see them, substitute your own user-friendly descriptions displayed in message boxes. MsgBox doesn't work in ASP.NET applications, though. You have to employ a different tactic. Find this section in Web.config :
<!-- CUSTOM ERROR MESSAGES
Team Fly |