473,386 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

About Error handling in ASPX pages

Hello,

I'm currently using Application_Error method in Global.asax.cs to handle
errors.

Recently, I heard about Page.ErrorPage and plan to use it for handling
errors on certain pages. Are there any major difference in using these
methods? My concern is mainly on the restrictions imposed on using these
method.

In my old error handling routine, I tried to use Server.GetLatError() to
get Exception object in the error page redirected by Response.Redirect() but
failed, can I use this method to retrieve the exception object in the new
page if Page.ErrorPage is used instead?

Thanks a lot.

Regards,
Lau Lei Cheong
--
If you want to mail to me, please replace all instance of "e" to "a" in my
email address. Thank you.
Sorry for any inconvience caused, but there's many spam-mailers.
Nov 18 '05 #1
5 1518
In ASP.NET you use structured exception handling via Try..End Try
statements. These statements allow you to catch exceptions, handle
different exceptions differently and keep your application going.

Try
some code that may throw an exception
Catch ex as Exception
some code to handle the exception
the exception itself is accessible via the variable name given to
it on the "Catch" line, so we can find out what type of exception we
have:

ex.getType.ToString

we can get the exception message:

ex.message
End Try

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:Om**************@TK2MSFTNGP09.phx.gbl...
Hello,

I'm currently using Application_Error method in Global.asax.cs to
handle
errors.

Recently, I heard about Page.ErrorPage and plan to use it for handling
errors on certain pages. Are there any major difference in using these
methods? My concern is mainly on the restrictions imposed on using these
method.

In my old error handling routine, I tried to use Server.GetLatError()
to
get Exception object in the error page redirected by Response.Redirect()
but
failed, can I use this method to retrieve the exception object in the new
page if Page.ErrorPage is used instead?

Thanks a lot.

Regards,
Lau Lei Cheong
--
If you want to mail to me, please replace all instance of "e" to "a" in my
email address. Thank you.
Sorry for any inconvience caused, but there's many spam-mailers.

Nov 18 '05 #2
You should also look into the
Microsoft.ApplicationBlocks.ExceptionManagement application block. It
provides some great functionality. Plus, they've already built and tested
it, so you don't have to.

"Scott M." <s-***@nospam.nospam> wrote in message
news:On**************@TK2MSFTNGP10.phx.gbl...
In ASP.NET you use structured exception handling via Try..End Try
statements. These statements allow you to catch exceptions, handle
different exceptions differently and keep your application going.

Try
some code that may throw an exception
Catch ex as Exception
some code to handle the exception
the exception itself is accessible via the variable name given to
it on the "Catch" line, so we can find out what type of exception we
have:

ex.getType.ToString

we can get the exception message:

ex.message
End Try

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:Om**************@TK2MSFTNGP09.phx.gbl...
Hello,

I'm currently using Application_Error method in Global.asax.cs to
handle
errors.

Recently, I heard about Page.ErrorPage and plan to use it for handling errors on certain pages. Are there any major difference in using these
methods? My concern is mainly on the restrictions imposed on using these
method.

In my old error handling routine, I tried to use Server.GetLatError()
to
get Exception object in the error page redirected by Response.Redirect()
but
failed, can I use this method to retrieve the exception object in the new page if Page.ErrorPage is used instead?

Thanks a lot.

Regards,
Lau Lei Cheong
--
If you want to mail to me, please replace all instance of "e" to "a" in my email address. Thank you.
Sorry for any inconvience caused, but there's many spam-mailers.


Nov 18 '05 #3
True. However since the page is used to handle exceptions not on specific
task(such as when ASP.NET detects dangerous value in Request.Form[]) and
also unexpected server error, I think a general form of error handling would
be more appropiate.

"Scott M." <s-***@nospam.nospam> ¦b¶l¥ó
news:On**************@TK2MSFTNGP10.phx.gbl ¤¤¼¶¼g...
In ASP.NET you use structured exception handling via Try..End Try
statements. These statements allow you to catch exceptions, handle
different exceptions differently and keep your application going.

Try
some code that may throw an exception
Catch ex as Exception
some code to handle the exception
the exception itself is accessible via the variable name given to
it on the "Catch" line, so we can find out what type of exception we
have:

ex.getType.ToString

we can get the exception message:

ex.message
End Try

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:Om**************@TK2MSFTNGP09.phx.gbl...
Hello,

I'm currently using Application_Error method in Global.asax.cs to
handle
errors.

Recently, I heard about Page.ErrorPage and plan to use it for handling errors on certain pages. Are there any major difference in using these
methods? My concern is mainly on the restrictions imposed on using these
method.

In my old error handling routine, I tried to use Server.GetLatError()
to
get Exception object in the error page redirected by Response.Redirect()
but
failed, can I use this method to retrieve the exception object in the new page if Page.ErrorPage is used instead?

Thanks a lot.

Regards,
Lau Lei Cheong
--
If you want to mail to me, please replace all instance of "e" to "a" in my email address. Thank you.
Sorry for any inconvience caused, but there's many spam-mailers.


Nov 18 '05 #4
Thanks for your information. This seems to be something interesting. :)

I'm learning how to build the interface through it.

"George Durzi" <gd****@hotmail.com> ¦b¶l¥ó
news:uI****************@TK2MSFTNGP10.phx.gbl ¤¤¼¶¼g...
You should also look into the
Microsoft.ApplicationBlocks.ExceptionManagement application block. It
provides some great functionality. Plus, they've already built and tested
it, so you don't have to.

"Scott M." <s-***@nospam.nospam> wrote in message
news:On**************@TK2MSFTNGP10.phx.gbl...
In ASP.NET you use structured exception handling via Try..End Try
statements. These statements allow you to catch exceptions, handle
different exceptions differently and keep your application going.

Try
some code that may throw an exception
Catch ex as Exception
some code to handle the exception
the exception itself is accessible via the variable name given to
it on the "Catch" line, so we can find out what type of exception we
have:

ex.getType.ToString

we can get the exception message:

ex.message
End Try

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:Om**************@TK2MSFTNGP09.phx.gbl...
Hello,

I'm currently using Application_Error method in Global.asax.cs to
handle
errors.

Recently, I heard about Page.ErrorPage and plan to use it for handling errors on certain pages. Are there any major difference in using these
methods? My concern is mainly on the restrictions imposed on using these method.

In my old error handling routine, I tried to use Server.GetLatError() to
get Exception object in the error page redirected by Response.Redirect() but
failed, can I use this method to retrieve the exception object in the new page if Page.ErrorPage is used instead?

Thanks a lot.

Regards,
Lau Lei Cheong
--
If you want to mail to me, please replace all instance of "e" to "a"
in
my email address. Thank you.
Sorry for any inconvience caused, but there's many spam-mailers.



Nov 18 '05 #5
I understand, but Page.ErrorPage isn't an error handler. It is just a
designation as to which page to show when there is an unhandled error.
"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:ea**************@tk2msftngp13.phx.gbl...
True. However since the page is used to handle exceptions not on specific
task(such as when ASP.NET detects dangerous value in Request.Form[]) and
also unexpected server error, I think a general form of error handling
would
be more appropiate.

"Scott M." <s-***@nospam.nospam> ¦b¶l¥ó
news:On**************@TK2MSFTNGP10.phx.gbl ¤¤¼¶¼g...
In ASP.NET you use structured exception handling via Try..End Try
statements. These statements allow you to catch exceptions, handle
different exceptions differently and keep your application going.

Try
some code that may throw an exception
Catch ex as Exception
some code to handle the exception
the exception itself is accessible via the variable name given to
it on the "Catch" line, so we can find out what type of exception we
have:

ex.getType.ToString

we can get the exception message:

ex.message
End Try

"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:Om**************@TK2MSFTNGP09.phx.gbl...
> Hello,
>
> I'm currently using Application_Error method in Global.asax.cs to
> handle
> errors.
>
> Recently, I heard about Page.ErrorPage and plan to use it for handling > errors on certain pages. Are there any major difference in using these
> methods? My concern is mainly on the restrictions imposed on using
> these
> method.
>
> In my old error handling routine, I tried to use
> Server.GetLatError()
> to
> get Exception object in the error page redirected by
> Response.Redirect()
> but
> failed, can I use this method to retrieve the exception object in the new > page if Page.ErrorPage is used instead?
>
> Thanks a lot.
>
> Regards,
> Lau Lei Cheong
> --
> If you want to mail to me, please replace all instance of "e" to "a" in my > email address. Thank you.
> Sorry for any inconvience caused, but there's many spam-mailers.
>
>



Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Leo R | last post by:
Hi all, If an error occurs in an aspx-page, you can configure the web.config in a way that the user automatically navigates to a certain page (e.g. error.aspx). My question: is it possible to...
14
by: Al Smith | last post by:
I need help in implementing proper error handling. I am trying to upload a file based on the sample code below. The code works well except if the file selected is too big. I do know about the...
2
by: A.M | last post by:
Hi, I have this code in my web.config: <customErrors mode="On" defaultRedirect="~/ErrorPages/ErrorApp.aspx"> <error statusCode="400" redirect="~/ErrorPages/Error.aspx" /> <error...
6
by: José Joye | last post by:
Hello, I'm currently reading the MS Developing Web applications with c# (and VB.net). In the chapter related to Error management, there is a sample about "Page-Level Error Pages" eg: In my...
3
by: Joel D. Kraft | last post by:
I've been logging a lot of fatal errors on my site lately, and I have not been able to figure out why. First, my site has error handling pages defined globally as shown below. They are not...
38
by: Arjang | last post by:
http://www.codeproject.com/useritems/CSharpVersusVB.asp
2
by: tshad | last post by:
This has been driving me crazy. I have been trying to get the error handling working on my system and can get parts of it working and others won't work at all. I found that you can't access...
1
by: David Thole | last post by:
Hey all, So far my reading is proving to be very interesting and good. This book is very helpful, and I'm generally left with quite a few questions about how I'm going to do stuff with my...
1
by: sean_walsh | last post by:
Hi From classic ASP, I had a custom error handling situation that was quite simple. Errors were all redirected to Error.asp. This page would check 2 settings, EmailErrorMessage and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.