473,326 Members | 2,147 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,326 software developers and data experts.

Application_Error being ignored

I am using VS2005 Professional, DOT.NET FrameWork 2.

During testing and debugging through the IDE using the development machine
LocalHost server whenever an error is encountered the Application_Error fires
OK and all code in the function is executed successfully.

When this application is deployed to the production (using a deployment
project). When errors occur the code in Application_Error is ignored
completely and the error is displayed using the DOT.NET standard error
reporting page.

I noticed that the Global.asax contains:
<%@ Application Codebehind="Global.asax.cs" Inherits="HRscapeLite.Global"
Language="C#" %>
only so I am assuming that the code is in the DLL.

Any help/suggestions is greatly appreciated.
Alex

Nov 6 '07 #1
2 2106
Do you have the code that appears in the Application_Error handler in
global.asax?
If it calls Server.ClearError this will prevent display of the error page.
You might want to post the actual code if you have it. if not, use Reflector
to decompile it out and examine.
--Peter
http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Alex Munk" wrote:
I am using VS2005 Professional, DOT.NET FrameWork 2.

During testing and debugging through the IDE using the development machine
LocalHost server whenever an error is encountered the Application_Error fires
OK and all code in the function is executed successfully.

When this application is deployed to the production (using a deployment
project). When errors occur the code in Application_Error is ignored
completely and the error is displayed using the DOT.NET standard error
reporting page.

I noticed that the Global.asax contains:
<%@ Application Codebehind="Global.asax.cs" Inherits="HRscapeLite.Global"
Language="C#" %>
only so I am assuming that the code is in the DLL.

Any help/suggestions is greatly appreciated.
Alex
Nov 6 '07 #2
I did some more digging. Here is the actual code:

protected void Application_Error(object sender, EventArgs e)
{
Exception objErr = new Exception();
objErr = Server.GetLastError().GetBaseException();

int EventID = 62300;
string err = "Error In: " + Request.Url.ToString() + "\r\n"
+ "Error Source: " + objErr.Source.ToString() + "\r\n"
+ "Error Message: " + objErr.Message.ToString() + "\r\n"
+ "Stack Trace: " + objErr.StackTrace.ToString() + "\r\n";

System.Diagnostics.EventLog.WriteEntry("MyApp", err,
System.Diagnostics.EventLogEntryType.Error, EventID);

Server.ClearError();

MailMessage mailMsg = new MailMessage();
mailMsg.From = new MailAddress("er***@XXXX.com");
mailMsg.To.Add("ab*@XXXX.com");
mailMsg.Subject = "Event ID " + EventID.ToString()
+ " in Application MyApp";
mailMsg.Body = err;
SmtpClient smtp = new SmtpClient("smtp.XXXX.com");
smtp.Credentials = new System.Net.NetworkCredential(
"UID", "PWD");
smtp.EnableSsl = true;
smtp.Send(mailMsg);

Response.Write("An error occured in the MyApp. "
+ "An e-mail alert was sent to support staff. "
+ "Please quote EVENT ID: " + EventID.ToString()
+ " when following up with customer support");

}

When I commented out:
System.Diagnostics.EventLog.WriteEntry("MyApp", err,
System.Diagnostics.EventLogEntryType.Error, EventID);
The email message was sent out. off course the event was not logged. So I am
assuming here that this boils down to a rights problem. so I reactivated
writing to the event log and gave ASPNET user Administrator priviledges. That
did not work.

Any Suggestions?

Nov 6 '07 #3

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

Similar topics

1
by: Greg Burns | last post by:
I am trying to write a global custom error page. I thought I would jot down some of what I've learned so far... At first I just used the default customErrors section with a defaultRedirect tag,...
2
by: A.M | last post by:
Hi, I have the following code in Global.asax. Using a breakpoint, i can see that that all errors are being trapped in Application_Error and the event handler is being run properly. The problem...
2
by: A.M | last post by:
Hi, I have the following code in Global.asax. Using a breakpoint, i can see that that all errors are being trapped in Application_Error and the event handler is being run properly. The problem...
6
by: Matt | last post by:
Can anyone give me a good reason to use BOTH application scope Page_Error and the page scope Page_Error when trapping errors in a web application? Is there any real benefit to using the Page_Error...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
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....
0
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...
0
isladogs
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...

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.