Skip Navigation LinksASP.Net 2.0 Training : ASP.Net:Error Handling
Banner for ASP.Net 2.0 training classes in Visual Basic 2005 

Skip Navigation Links
Visit my other site:

certification training

Free Flash tutorials and training

Free Dreamweaver Video Tutorials

Free PHP Training

Visual Basic Windows Training




If you like this site please link to it


Error Handling
Try Catch Blocks


Open your web.config file
Set debug to true in web.config

  • Add a new webform
  • Type Generate an exception
  • Add a button
  • Double-click the button and add this code:

Dim test as string=nothing
Response.write(test.toString( ) )

This will cause an exception

  • Test it


Add try catch around it

Try
Dim test as string=nothing
Response.write(test.toString( ) )
Catch ex as exception
Response.write(string.concat(“An error occurred”,ex.message)
End try

Generates a generic exception

Modify it:
Try
Dim test as string=nothing
Response.write(test.toString( ) )
Catch nex as nullreferenceexception
          Response.write(string.concat(“The variable was not initialized”))

Catch ex as exception
Response.write(string.concat(“An error occurred”,ex.message)
End try

 

Exception handling stops trying to catch once an exception is handled

Put specific handlers first
Put generic handlers last


      ASP.Net 2.0 tutorials & training