473,748 Members | 9,913 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

About Error handling in ASPX pages

Hello,

I'm currently using Application_Err or 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.GetLatEr ror() to
get Exception object in the error page redirected by Response.Redire ct() 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 1525
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.ToSt ring

we can get the exception message:

ex.message
End Try

"Lau Lei Cheong" <le****@yehoo.c om.hk> wrote in message
news:Om******** ******@TK2MSFTN GP09.phx.gbl...
Hello,

I'm currently using Application_Err or 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.GetLatEr ror()
to
get Exception object in the error page redirected by Response.Redire ct()
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.Appli cationBlocks.Ex ceptionManageme nt 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.nosp am> wrote in message
news:On******** ******@TK2MSFTN GP10.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.ToSt ring

we can get the exception message:

ex.message
End Try

"Lau Lei Cheong" <le****@yehoo.c om.hk> wrote in message
news:Om******** ******@TK2MSFTN GP09.phx.gbl...
Hello,

I'm currently using Application_Err or 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.GetLatEr ror()
to
get Exception object in the error page redirected by Response.Redire ct()
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.nosp am> ¦b¶l¥ó
news:On******** ******@TK2MSFTN GP10.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.ToSt ring

we can get the exception message:

ex.message
End Try

"Lau Lei Cheong" <le****@yehoo.c om.hk> wrote in message
news:Om******** ******@TK2MSFTN GP09.phx.gbl...
Hello,

I'm currently using Application_Err or 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.GetLatEr ror()
to
get Exception object in the error page redirected by Response.Redire ct()
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******** ********@TK2MSF TNGP10.phx.gbl ¤¤¼¶¼g...
You should also look into the
Microsoft.Appli cationBlocks.Ex ceptionManageme nt 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.nosp am> wrote in message
news:On******** ******@TK2MSFTN GP10.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.ToSt ring

we can get the exception message:

ex.message
End Try

"Lau Lei Cheong" <le****@yehoo.c om.hk> wrote in message
news:Om******** ******@TK2MSFTN GP09.phx.gbl...
Hello,

I'm currently using Application_Err or 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.GetLatEr ror() to
get Exception object in the error page redirected by Response.Redire ct() 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.c om.hk> wrote in message
news:ea******** ******@tk2msftn gp13.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.nosp am> ¦b¶l¥ó
news:On******** ******@TK2MSFTN GP10.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.ToSt ring

we can get the exception message:

ex.message
End Try

"Lau Lei Cheong" <le****@yehoo.c om.hk> wrote in message
news:Om******** ******@TK2MSFTN GP09.phx.gbl...
> Hello,
>
> I'm currently using Application_Err or 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.GetLatEr ror()
> to
> get Exception object in the error page redirected by
> Response.Redire ct()
> 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
1375
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 catch the stacktrace of the error in error.aspx so it can be logged? The error has been catched somewhere in order to perform the reroute to error.aspx. So where are the error-details?
14
3892
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 maxRequestLength parameter of the <httpRuntime> section and that works as expected. What I want is to enforce a max file size but haven't been able to trap the error thrown when the file is too large and that's where I could use some help.
2
3305
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 statusCode="401" redirect="~/ErrorPages/Error.aspx" /> <error statusCode="403" redirect="~/ErrorPages/Error.aspx" /> <error statusCode="404" redirect="~/ErrorPages/Error.aspx" /> <error statusCode="408" redirect="~/ErrorPages/Error.aspx" />
6
4603
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 form: ========
3
1298
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 overridden at any point in the configuration. <customErrors mode="RemoteOnly" defaultRedirect="/site/error/default.aspx"> <error statusCode="404" redirect="/site/error/404.aspx" /> </customErrors>
38
1735
by: Arjang | last post by:
http://www.codeproject.com/useritems/CSharpVersusVB.asp
2
2142
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 session variables from Application_Error event, but I need to so I don't need to set up traces to see what they are during an error. I am emailing the error condition to myself when it happens.
1
1514
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 current setup. Basically speaking, all my stuff is currently in PHP. I need the ability for being able to interact with PHP quite a bit. My largest question right now, is say that I want to provide some information from my PHP form to the asp one...
1
1773
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 DisplayErrorMessage. If EmailErrorMessage was true, it would send an email with the error details. If DisplayErrorMessage was true, it would display the message on screen. Also, if an Administrator was logged in, it would display the message as they could...
0
8984
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9530
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9312
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9238
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.