I need to be able to trap errors at the application level. I added this code
to the Global.asax file. The code I wrote is supposed to get the last error
that was generated and write to the event log as well as fire up my email
class and generate an email to send me the error. But no matter what I do, I
still get the icky looking yellow and white error screens.
I’ve turned on customErrors in the web.config but not default URL setting.
The pages don’t have Page_Error method in them so I would except the error to
move next up in the hierarchy which would be Application_Error. There are so
many pages in this project, I really cant trap general errors at the page
level. What am I doing wrong?????
protected void Application_Error(Object sender, EventArgs e)
{
Exception objErr = Server.GetLastError().GetBaseException();
string err ="Error Caught in Application_Error event\n" +
"Error in: " + Request.Url.ToString() +"\nError Message:" +
objErr.Message.ToString()+ "\nStack Trace:" + objErr.StackTrace.ToString();
EventLog.WriteEntry("Sample_WebApp",err,EventLogEn tryType.Error);
Server.ClearError();
classes.email Email = new classes.email();
bool Status = Email.GenerateEmail("ERROR",null,err.ToString());
Response.Redirect("errorpage.aspx");
}
--
JP
..NET Software Developer 3 3274
By the time this event fires, it is too late to do a redirect. There is no
request at this point.
If you want to have central error handling, but be able to redirect, then
create a base page class that handles the error event. Then have every other
page in your application inherit from this page.
"JP" <JP@discussions.microsoft.com> wrote in message
news:30**********************************@microsof t.com... I need to be able to trap errors at the application level. I added this code to the Global.asax file. The code I wrote is supposed to get the last error that was generated and write to the event log as well as fire up my email class and generate an email to send me the error. But no matter what I do, I still get the icky looking yellow and white error screens.
I've turned on customErrors in the web.config but not default URL setting. The pages don't have Page_Error method in them so I would except the error to move next up in the hierarchy which would be Application_Error. There are so many pages in this project, I really cant trap general errors at the page level. What am I doing wrong?????
protected void Application_Error(Object sender, EventArgs e) {
Exception objErr = Server.GetLastError().GetBaseException(); string err ="Error Caught in Application_Error event\n" + "Error in: " + Request.Url.ToString() +"\nError Message:" + objErr.Message.ToString()+ "\nStack Trace:" + objErr.StackTrace.ToString();
EventLog.WriteEntry("Sample_WebApp",err,EventLogEn tryType.Error); Server.ClearError(); classes.email Email = new classes.email(); bool Status = Email.GenerateEmail("ERROR",null,err.ToString()); Response.Redirect("errorpage.aspx");
}
-- JP .NET Software Developer
Ok, excluding the redirect line of code. At the point Im saying its noteven
getting to this point. My understanding was that all application error with
the exception of http error, ie 404,500 ect get passed to the
Application_Error method in the global.asax if there is no Page_Error method
to handle an error at the page level. Its as though it never makes it to the
global.asax.
Strange that intllisense will allow Response.Redirect but that you cant use
it. I see ehat your saying to do, Im just trying to understand that
everything Ive read says errors get passed to this method, yet Im not getting
ANY results.
Thoughts?
--
JP
..NET Software Develper
"Marina" wrote: By the time this event fires, it is too late to do a redirect. There is no request at this point.
If you want to have central error handling, but be able to redirect, then create a base page class that handles the error event. Then have every other page in your application inherit from this page.
"JP" <JP@discussions.microsoft.com> wrote in message news:30**********************************@microsof t.com...I need to be able to trap errors at the application level. I added this code to the Global.asax file. The code I wrote is supposed to get the last error that was generated and write to the event log as well as fire up my email class and generate an email to send me the error. But no matter what I do, I still get the icky looking yellow and white error screens.
I've turned on customErrors in the web.config but not default URL setting. The pages don't have Page_Error method in them so I would except the error to move next up in the hierarchy which would be Application_Error. There are so many pages in this project, I really cant trap general errors at the page level. What am I doing wrong?????
protected void Application_Error(Object sender, EventArgs e) {
Exception objErr = Server.GetLastError().GetBaseException(); string err ="Error Caught in Application_Error event\n" + "Error in: " + Request.Url.ToString() +"\nError Message:" + objErr.Message.ToString()+ "\nStack Trace:" + objErr.StackTrace.ToString();
EventLog.WriteEntry("Sample_WebApp",err,EventLogEn tryType.Error); Server.ClearError(); classes.email Email = new classes.email(); bool Status = Email.GenerateEmail("ERROR",null,err.ToString()); Response.Redirect("errorpage.aspx");
}
-- JP .NET Software Developer
What if you are using a bare bone sub such as adding 1 to a counter and
seeing on another page if its change ?
My first goal would be to see if this is triggered or if there is some kind
of error in trapping the error that prevents this.
Also try to use off in the web.config for a start. The normal process is
that you would go to the custom page after the global handler. This might be
the problem.
--
Patrice
"JP" <JP@discussions.microsoft.com> a écrit dans le message de
news:9B**********************************@microsof t.com... Ok, excluding the redirect line of code. At the point Im saying its
noteven getting to this point. My understanding was that all application error
with the exception of http error, ie 404,500 ect get passed to the Application_Error method in the global.asax if there is no Page_Error
method to handle an error at the page level. Its as though it never makes it to
the global.asax.
Strange that intllisense will allow Response.Redirect but that you cant
use it. I see ehat your saying to do, Im just trying to understand that everything Ive read says errors get passed to this method, yet Im not
getting ANY results.
Thoughts? -- JP .NET Software Develper
"Marina" wrote:
By the time this event fires, it is too late to do a redirect. There is
no request at this point.
If you want to have central error handling, but be able to redirect,
then create a base page class that handles the error event. Then have every
other page in your application inherit from this page.
"JP" <JP@discussions.microsoft.com> wrote in message news:30**********************************@microsof t.com...I need to be able to trap errors at the application level. I added this code to the Global.asax file. The code I wrote is supposed to get the last error that was generated and write to the event log as well as fire up my
email class and generate an email to send me the error. But no matter what I
do, I still get the icky looking yellow and white error screens.
I've turned on customErrors in the web.config but not default URL
setting. The pages don't have Page_Error method in them so I would except the
error to move next up in the hierarchy which would be Application_Error. There
are so many pages in this project, I really cant trap general errors at the
page level. What am I doing wrong?????
protected void Application_Error(Object sender, EventArgs e) {
Exception objErr = Server.GetLastError().GetBaseException(); string err ="Error Caught in Application_Error event\n" + "Error in: " + Request.Url.ToString() +"\nError Message:" + objErr.Message.ToString()+ "\nStack Trace:" + objErr.StackTrace.ToString();
EventLog.WriteEntry("Sample_WebApp",err,EventLogEn tryType.Error); Server.ClearError(); classes.email Email = new classes.email(); bool Status = Email.GenerateEmail("ERROR",null,err.ToString()); Response.Redirect("errorpage.aspx");
}
-- JP .NET Software Developer This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: JP |
last post by:
I need to be able to trap errors at the application level. I added this code
to the Global.asax file. The code I wrote is supposed to get the last error
that was generated and write to the event...
|
by: Luther Hert |
last post by:
While trying to work through textbook lessons for Vb.net
Step by Step,Version 2003, Chapter 22, the first step is
to create a new Web application Project,using the ASP.Net
Application icon in the...
|
by: paul downing via DotNetMonster.com |
last post by:
global file email send
--------------------------------------------------------------------------------
guys, i'm developing an application and want to send an email with an error if it occurs...
|
by: fd123456 |
last post by:
Hi Tom !
Sorry about the messy quoting, Google is playing tricks on me at the
moment.
> Global.asax is where you normally have the Global Application
> and Session variables and code to...
|
by: Michael Tissington |
last post by:
How do I specify the CodeFile for my Global.asax file ?
According to the documentation I can use the CodeFile attribute with
Application, however when I try to use this I get an error saying that...
|
by: seanmccormick1 |
last post by:
We are having trouble trapping errors that occur in the WSE 2.0 code.
Our error handling/logging for our web services happens in the
Global.asax Application_OnError method, but it does not seem to...
|
by: Anonieko |
last post by:
Global.asax? Use HttpModules Instead!
In a previous post, I talked about HttpHandlers - an underused but
incredibly useful feature of ASP.NET. Today I want to talk about
HttpModules, which are...
|
by: Doug |
last post by:
Visual Studio 2005, SQL Server 2000, ASP.NET/VB.NET
Not allowed to use the ASPNET machine account in SQL Server (very
strict environment).
Need to use Windows authentication, so we use...
|
by: Al Santino |
last post by:
Hello,
I've created a simple C# web services project using Visual Studio 2005. My
service compiles and runs correctly when called by remote clients.
I'm able to step through the service in the...
|
by: thefritz_j |
last post by:
We just converted our VS2003 1.1 VB web project (which was working
fine) to VS2005 2.0 and now I get:
Parser Error Message: Could not load type '<Namespace>.'.
Source Error:
Line 1: <%@...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |