Error handling in ASP.NET

Preview:

Citation preview

Disclaimer: This presentation is prepared by trainees ofbaabtra as a part of mentoring program. This is not officialdocument of baabtra –Mentoring PartnerBaabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .Ltd

Week Target Achieved

1 30 23

2 30 26

3 30 25

Typing Speed

Jobs Applied

Week Company Designation Applied Date Current Status

1

2

3

Error Handling in Asp .net

Muhammed Ajaml

mhdajmalik@gmail.com

www.facebook.com/ajuik

twitter.com/username

in.linkedin.com/in/profilename

9745020951

Exception

• Exceptions are unforeseen errors that happen within

the logic of an application.

– File not found

– Unautherised access

– Argument NullException

– Arithmetic Exception

Unhandled exception

• When an exception occurs and if it is not handled.

Unhandled exception

• An unhandled exception is displayed to the user using

an”yellow screen of death”

Disadvantage of yellow screen of

death. The error messages are cryptic and may not make any

sense to the end user

. The exception information may be useful for a hacker,

to hack into your application

Exception handling using - try-

catchTry

{

Wrap the code in a try block that could possibly cause an

exception

}

Catch(Exception e)

{//handle errors}

Finally

{//Used to free resources.}

Example

• A program to read data from XML file and display it

to the Grid View

Countries.xml

Bind to gridview

Show Data

File not found Exception

Error

Try –catch-finally

Show Error

Unauthorised Exception

Show Error

Asp .net Error Events

• Page_Error

– Used in page level

– This event raised whenever an unhandled exception occurs

in the page.

• Application_Error– Used in application level

– This event raised whenever an unhandled exception occurs

in the application.

Page_Error Example

Yellow screen death

Page_error

Errors.aspx

Application_Error

• When there is an unhandled exception at an

application level.

• The event handler resides in Global.asax file

Contd..

Thank You

If this presentation helped you, please visit our page facebook.com/baabtra and like it.

Thanks in advance.

www.baabtra.com | www.massbaab.com |www.baabte.com

Contact Us

Emarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550

Start up VillageEranakulam,Kerala, India.

Email: info@baabtra.com

IKK Road,East Hill, KozhikodeKerala, India.Ph: + 91 – 495 30 63 624

NIT-TBI,NIT Campus, Kozhikode,Kerala, India.