Writing an exception to both the event log and to an error page

N

Nam

In a C# class of an ASP.NET application, I am logging the exceptions to the
windows even log. How can I simultaneously propagate the exception on top and
let the Page that calls that C# class to catch the exception?

After catching the exception, I would redirect a customized message to an
error page.

Thank you in advance.
 
J

JJ

Should just have to rethrow it.

Try
<code>
Catch Ex as Exception
<code here to log to event log>
Throw Ex
End Try
 
S

sloan

I would try this, which I think keeps the original stack trace.


try
{

}
catch (Exception ex)
{

//publish it to the event log
throw;

}


Or change it to
throw ex;

But there is a subtle difference.
 

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

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top