Last post Sep 11, 2013 07:56 AM by PatriceSc
Sep 08, 2013 05:58 AM|kevinof|LINK
I have a new project and a custom error page set up. When an exception or error happens the custom error page gets called but applicatin_error in global.asax never gets called. Other subs in global.asax are working fine (application_start etc). All I have
right now in application_error is a simple trace.write to say "hi I got here" so I know there is nothing in global causing a second exception.
Any ideas? I have this working on other apps but can't get this working on this one.
Sep 09, 2013 06:53 AM|PatriceSc|LINK
Have you double checked the procedure name ? I assume that "applicatin_error" is a typo and is NOT the real name you have in global.asax ? You may want to show what is the full signature you used...
Sep 09, 2013 07:26 AM|kevinof|LINK
Just a typo. I'm using Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Sep 09, 2013 08:01 AM|Angie xu - MSFT|LINK
void Application_Error(object sender, EventArgs e)
// Code that runs when an unhandled error occurs
Exception objErr = Server.GetLastError().GetBaseException();
string err = "Error Caught in Application_Error event\n" + "Error in:"
+ Request.Url.ToString() + "\nError Message:" + objErr.Message.ToString()
+ "\nStack Trace:" + objErr.StackTrace.ToString();
EventLog.WriteEntry("Sample_WebApp", err, EventLogEntryType.Error); Server.ClearError();
I use the codes above to get error on my side, it works fine, I think it is also available for you, or you could post your codes, we will give more precise troubleshooting for you,
Sep 09, 2013 08:33 AM|kevinof|LINK
That's not going to work. Like I said in the first post application_error is getting even getting called.
Sep 10, 2013 09:51 AM|Ruchira|LINK
Please note that application_error in global.asax file will only get fired for unhandled exceptions. You need to remove try catch blocks.
Please 'Mark as Answer' if this post helps you
Sep 10, 2013 05:50 PM|kevinof|LINK
Yep I'm aware of that. No try statements here. This one's doing my head in. Any other way to get the last error visible in my customer error page? It comes in as null at the moment so it's not being passed along.
Sep 11, 2013 05:13 AM|cnranasinghe|LINK
Hope this is not a web service project. Have a look @
Sep 11, 2013 05:15 AM|kevinof|LINK
No just a web form apps. Think I'm going to cry
Sep 11, 2013 05:50 AM|cnranasinghe|LINK
this thread, may be similar setting on your web.config.
Sep 11, 2013 07:56 AM|PatriceSc|LINK
As you are using VB what if you add a
http://msdn.microsoft.com/en-us/library/6k46st1y.aspx (handles) clause to make 100% sure this event handler is attached.
Also I assume that you have a test page that does nothing else that throws explicitely an exception when you click a button for example and that have *NO* other content except that.
BTW if it is not called, what is the behavior you see ? Do you see the "yellow page" ? I noticed you told about a trace (but it is still possible that it runs without the trace being shown for some reason).
What if you use a Stop statement inside this handler or put a breakpoint (and in this case put a breakpoint as well in some other global.asax procedure to make sure breakpoints are ok). If you see the "yellow page" it could be that Server.ClearError is not