Groups | Blog | Home
all groups > asp.net > may 2005 >

asp.net : Application_Error ???


Daniel Groh
5/11/2005 11:33:33 PM
Hi, I have this code in my Application_Error:

protected void Application_Error(Object sender, EventArgs e)
{
Exception ex = Context.Error.GetBaseException();
string msgErro = ex.Message + " - " + ex.StackTrace;
if(!EventLog.SourceExists("BooksOnline"))
{
EventLog.CreateEventSource("BooksOnline","BooksOnline Log");
}
System.Web.Mail.SmtpMail.SmtpServer = "localhost";
System.Web.Mail.SmtpMail.Send("errorapp@booksonline.com.br",
"admin@booksonline.com.br",
"Application Error",
ex.Message);
EventLog.WriteEntry("BooksOnline",msgErro,EventLogEntryType.Error);
}

It does not work...I already tryed the code that is sending email and
everything is running ok, but it is not going to Application_Error, should I
specify something in my web.config ? it's now RemoteOnly!

Thanks in advance

Daniel

Brock Allen
5/12/2005 8:21:23 AM
You typically need to be an admin to call:

EventLog.CreateEventSource("BooksOnline","BooksOnline Log");

Which is not the default identity for the ASP.NET worker process. You should
run a little admin tool to do this one line of code on the target machine.

-Brock
DevelopMentor
http://staff.develop.com/ballen



[quoted text, click to view]


AddThis Social Bookmark Button