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
George Ter-Saakov - 06 Mar 2008 12:48 GMT
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.
> Hi Guys,
>
[quoted text clipped - 14 lines]
> with Regards,
> Mustaq Ahmed.A
sloan - 06 Mar 2008 19:40 GMT
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.
> Hi Guys,
>
[quoted text clipped - 14 lines]
> with Regards,
> Mustaq Ahmed.A