473,387 Members | 1,520 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,387 software developers and data experts.

Catching ASP.NET errors

Hello,

When an unhandled exception occurs on an ASP.NET page, a well known page
will appear, having the header "Server Error in '[app path]' Application"
and the Exception Details and Stack Trace below it.

Is it possible to customize this page and for example save to exception
info in a database and display a custom message to the user.

Does anybody know if this is possible?
--
Mikael Engdahl

Nov 17 '05 #1
3 1380
There is an Error event in the page class. If you handle it, you can do
whatever you want, including making sure that this error page never displays
at all.

There is also an Application_Error event in Global.asax, which handles
unhandled errors from the entire application.

"Mikael Engdahl" <mi******@engdahl.no.spam.com> wrote in message
news:uJ**************@tk2msftngp13.phx.gbl...
Hello,

When an unhandled exception occurs on an ASP.NET page, a well known page
will appear, having the header "Server Error in '[app path]' Application"
and the Exception Details and Stack Trace below it.

Is it possible to customize this page and for example save to exception
info in a database and display a custom message to the user.

Does anybody know if this is possible?
--
Mikael Engdahl

Nov 17 '05 #2
I would recommend writing your own page class that will handle the errors
experience on every page. It saves you from having to put the
Page.OnError() method of every page.

I used to use Application_OnError but I could consistently have access to
the session variables that held user information, and I was trying to catch
the sql query used that crashed the page (usually that is where the
Exceptions are for my project).

bill

"Mikael Engdahl" <mi******@engdahl.no.spam.com> wrote in message
news:uJ**************@tk2msftngp13.phx.gbl...
Hello,

When an unhandled exception occurs on an ASP.NET page, a well known page
will appear, having the header "Server Error in '[app path]' Application"
and the Exception Details and Stack Trace below it.

Is it possible to customize this page and for example save to exception
info in a database and display a custom message to the user.

Does anybody know if this is possible?
--
Mikael Engdahl

Nov 17 '05 #3
Mikael,

Yes, you can customize what page is shown using the web.config file.

Here's a link that shows exactly how to do this:

http://www.devasp.net/Net/Articles/A...tomErrors2.asp
Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Mikael Engdahl" <mi******@engdahl.no.spam.com> wrote in message
news:uJ**************@tk2msftngp13.phx.gbl...
Hello,

When an unhandled exception occurs on an ASP.NET page, a well known page
will appear, having the header "Server Error in '[app path]' Application"
and the Exception Details and Stack Trace below it.

Is it possible to customize this page and for example save to exception
info in a database and display a custom message to the user.

Does anybody know if this is possible?
--
Mikael Engdahl

Nov 17 '05 #4

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

Similar topics

1
by: Florian Fredegar Haftmann | last post by:
Hi! I'm working on a tool which helps in testing applications with web-frontends (on Windows) On thing I would like to test ist the occurence of JavaScript errors; the idea is that the test...
2
by: PapaBear | last post by:
Hi y'all, I'm handling Apache errors through seperate shtml files. That surely looks better than the standard error pages by the browser etc. I did this by coding in httpd.conf lines like: ...
2
by: fred | last post by:
Hello, I read a file from several classes and want to catch an EOF when it appears. Having caught the EOF I want to allow the final part of the program to continue rather than just exiting. ...
7
by: cmay | last post by:
FxCop complains every time I catch System.Exception. I don't see the value in trying to catch every possible exception type (or even figuring out what exceptions can be caught) by a given block...
0
by: R. MacDonald | last post by:
Hi, I have a VB.Net application that dynamically calls unmanaged routines in a DLL that has been created by Fortran (DVF v5). The call to the DLL routine is within a Try/Catch block, but when...
2
by: Eric Lilja | last post by:
Hello, consider this complete program: #include <iostream> #include <string> using std::cout; using std::endl; using std::string; class Hanna {
1
by: Hari Sekhon | last post by:
I've written an except hook into a script as shown below which works well for the most part and catches exceptions. import sys def myexcepthook(type,value,tb): do something ...
4
by: John Pye | last post by:
Hi all I have some C code that is giving me some 'nan' values in some calculations. The C code is wrapped using SWIG to give me a Python module that I am then exercising through a unittest...
25
by: JJ | last post by:
I only want to catch 404 errors at the application level (the rest are will be handled by the customerrors section of the web.config). How do I check for the error code in the Application_Error...
3
by: john | last post by:
I wrapped some fortran code using F2PY and need to be able to catch fortran runtime errors to run the following: # "grid" is a wrapped fortran module # no runtime errors incurred when run with...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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
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...

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.