Application_Error being ignored

G

Guest

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
 
G

Guest

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("(e-mail address removed)");
mailMsg.To.Add("(e-mail address removed)");
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top