By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,836 Members | 1,768 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,836 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.