Exception handling

A

a.mustaq

Hi Guys,

I am developing a asp.net application.In this I have
to handle exceptions in application level. When ever an an exception
occurs in any part of the application it should be hanldeld at a
single point. If some type of exception occurs the execution flow
should continue and if other type of excetion occurs it should
redirect to an error page.

I have tried this by hadling exceptions in
Applicatio_Error event of Global.asax.Whenever an exception occurs it
is redirecting to error page but i am unable to continue the flow of
execution when some type of exceptions are occured.

Plz.help me in acheving this.

with Regards,
Mustaq Ahmed.A
 
G

George Ter-Saakov

You got to use

try
{
.......
}
catch( MyTypeOfException)
{
......
}
in your code if you want to continue execution flow if MyTypeOfException
type had happened

The rest is correct approach. Handle it in Application_Error and Log it or
send yourself an email with Exception details.


George.
 
S

sloan

This is my approach.

Each webpage is kind of its own little world.

So I create a class...a common helper


public class ExceptionHandler
{
public void MainStreamHandleException ( Page p , Exception ex , bool
redirectToCommon )
{


//what i do is log the exception , but you can do what you want

//have "p" allows you to redirect if you need to
if(redirectToCommon )
{
p.Response.Redirect ('~/UnhandledException.aspx'); //whatever you want to do
}

}

}




NOW...in each aspx.cs file...I do this

page_load

try
{
//load data ..etc . etc

}
catch(Exception ex)
{

ExceptionHandler.MainStreamHandleException (this.Page, ex);

}

If I have a submit button I have to do the same thing.

button_one_click
{
try
{
// Save an Employee?? whatever action you have

}
catch(Exception ex)
{

ExceptionHandler.MainStreamHandleException (this.Page, ex);

}
}


Its not super cool....but it allows me a little bit of control.

There's probably a better solution..I'm just sharing what I do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top