Page 120 - DCAP312_WEB_TECHNOLOGIES_II
P. 120
Web Technologies-II
Notes Run to observe the effects:
aspx.page Begin PreLoad
aspx.page End PreLoad
aspx.page Begin Load
Page Load
Not Post Back, Page Load
aspx.page End Load
aspx.page Begin LoadComplete
aspx.page End Load Complet
To check the Warn method, let us forcibly enter some erroneous code in the selected index
changed event handler:
try
{
i n t a = 0 ;
int b = 9 / a;
}
catch (Exception e)
{
Trace.Warn( “UserAction”, “processing 9/a”, e);
}
Try-Catch is a C# programming construct. The try block holds any code that may or may not
produce error and the catch block catches the error. When the program is run, it sends the
warning in the trace log.
Aspx.page Begin Raise changedEvents
Processing 9/a
Attempted to divide by zero
UserAction
At errorhandling_Default.ddlquotes_SelectedIndexChanged(Object sender,EventArgs e) in)
Application level tracing applies to all the pages in the web site. It is implemented by putting
the following code lines in the web.config file:
<system.web>
<trace enabled= “true” />
</system.web>Error Handling
Although ASP.Net can detect all runtime errors, still some subtle errors may still be there.
Observing the errors by tracing is meant for the developers, not for the users.
Hence, to intercept such occurrence, you can add error handing settings in the web.config file of
the application. It is application wide error handling. For example, you can add the following
lines in the web.config file:
<configuration>
<system.web>
<customErrors mode= “RemoteOnly”
defaultRedirect= “GenericErrorPage.htm”>
<error statusCode= “403” redirect= “NoAccess.htm” />
<error statusCode= “404” redirect= “FileNotFound.htm” />
114 LOVELY PROFESSIONAL UNIVERSITY