469,928 Members | 1,900 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,928 developers. It's quick & easy.

global.asax: Application_Error how to get informations about the exception

Hi, is it possible to get informations about the exception that
occured in that method??

(global.asax)
protected void Application_Error(Object sender, System.EventArgs e) {

}

thanks for help
John
Nov 19 '05 #1
3 2304
Yes..

You can write for ex,

protected void Application_Error(Object sender, System.EventArgs e)
{
System.Web.HttpContext context = HttpContext.Current;
System.Exception e= Context.Server.GetLastError();

LogError(e); //Your own logging function...

context.Server.ClearError();

Response.Redirect("some_error_occured_we_are_sorry .aspx");

}

Hope this helps

-Rajesh
http://www.sharpVoice.com
"John Holgerson" <do**********@web.de> wrote in message
news:f9**************************@posting.google.c om...
Hi, is it possible to get informations about the exception that
occured in that method??

(global.asax)
protected void Application_Error(Object sender, System.EventArgs e) {

}

thanks for help
John

Nov 19 '05 #2
We recently discussed this:

http://groups-beta.google.com/group/...ff7fc1db95c1c7

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi, is it possible to get informations about the exception that
occured in that method??

(global.asax)
protected void Application_Error(Object sender, System.EventArgs e) {
}

thanks for help
John


Nov 19 '05 #3
Hi John,

You can try the foolowing code snippet to do the same:

<%@ Application Language="C#" %>
<%@ Import Namespace="System.Diagnostics" %>

<script language="C#" runat="server">
void Application_Error(object sender, EventArgs e)
{

Exception ex = Server.GetLastError().GetBaseException();

EventLog.WriteEntry("Test Web",
"MESSAGE: " + ex.Message +
"\nSOURCE: " + ex.Source +
"\nFORM: " + Request.Form.ToString() +
"\nQUERYSTRING: " + Request.QueryString.ToString() +
"\nTARGETSITE: " + ex.TargetSite +
"\nSTACKTRACE: " + ex.StackTrace,
EventLogEntryType.Error);
}
</script>

HTH

Mona[Grapecity]

"John Holgerson" <do**********@web.de> wrote in message
news:f9**************************@posting.google.c om...
Hi, is it possible to get informations about the exception that
occured in that method??

(global.asax)
protected void Application_Error(Object sender, System.EventArgs e) {

}

thanks for help
John

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by vbMental | last post: by
14 posts views Thread by paul downing via DotNetMonster.com | last post: by
7 posts views Thread by Jonas | last post: by
2 posts views Thread by tshad | last post: by
1 post views Thread by Anonieko | last post: by
19 posts views Thread by furiousmojo | last post: by
1 post views Thread by paulo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.