In previous non Umbraco .Net solutions we implemented custom error handling in the Global.asax code behind files Application_Error event and are trying to do something similar for our new Umbraco 7 project. Could someone direct me how to do this in Umbraco 7 as none of my attempts have worked. I tried adding a new code behind but the code was never hit.
I was able to figure out how to add an Application_Error method, but now it is being called twice for every error. Anyone have any idea why this may be happening?
How did you achieve this in the end? I've overridden UmbracoApplication but my "protected override void OnApplicationError(object sender, EventArgs e)" isn't getting hit.
The temporary solutuon I have in place is a simple try catch block in the Application_Error procedure where I also clear the error the first time trhough. This way the second call would not work so it goes to the catch block and does not execute all of the code. I would still love to know why it is even called twice but I have already invested tons of time into that with no solution. So if anyone knows about that please let me know. If you need more info on my work around just let me know
I cannot pass all of the code along. Do you just want my Application_Error procedure? I think your issue could be something in the web.config or Umbraco config as I too had a similar issue but do not remember how I fixed it.
and then I have my Global.asax.cs file where the code behind runs. I kind of remember the issue was originally that my .asax file was not referencing the CS file corretly
I m having same issue and also I m a little new to Umbraco. if i m correct in Umbraco 7 we don't have a global file. Is it ok if I add as Mark suggested ? will there be any issues ?
@Andy I have exectly same issue as you were facing. Can you please guide how you handled ? I have added event but on error its not being hit. Can you please help.
<%@ Application Codebehind="Global.asax.cs" Inherits="Umbraco.Web.UmbracoApplication" Language="C#" %> <script RunAt="server"> void Application_Error(object sender, EventArgs e) { // Code to get the error message and send me an e-mail with the details.
With every error, I get two identical error messages :/ What's happening?
I am working on a solution similar to Andy Neil's above -- but a dumb question for everyone -- with regard to the namespace / custom global class referred to in the Inherits="" attribute in Global.asax -- where should/does this class live? App_Code? I've got an override method I want to implement but i don't know where to put it!
public class MyGlobalApplication : UmbracoApplicationBase
{
public MyGlobalApplication ()
{
//UmbracoApplicationBase is an abstract class
ApplicationEnd += MyGlobalApplication _ApplicationEnd;
}
private void MyGlobalApplication _ApplicationEnd(object sender, EventArgs e)
{
//do whatever you like in here
}
}
Application_Error and Global.asax.cs
In previous non Umbraco .Net solutions we implemented custom error handling in the Global.asax code behind files Application_Error event and are trying to do something similar for our new Umbraco 7 project. Could someone direct me how to do this in Umbraco 7 as none of my attempts have worked. I tried adding a new code behind but the code was never hit.
I was able to figure out how to add an Application_Error method, but now it is being called twice for every error. Anyone have any idea why this may be happening?
Hi Mark,
How did you achieve this in the end? I've overridden UmbracoApplication but my "protected override void OnApplicationError(object sender, EventArgs e)" isn't getting hit.
Thanks,
Andy
Mine still appears to be getting called twice, which until I find out why I implented code to stop it from running the entire error routine twice.
Mark: Can you please share your solution?
The temporary solutuon I have in place is a simple try catch block in the Application_Error procedure where I also clear the error the first time trhough. This way the second call would not work so it goes to the catch block and does not execute all of the code. I would still love to know why it is even called twice but I have already invested tons of time into that with no solution. So if anyone knows about that please let me know. If you need more info on my work around just let me know
You are one step ahead of me, I can't get the Application_Error procedure to fire.
Can you pass along your code?
I cannot pass all of the code along. Do you just want my Application_Error procedure? I think your issue could be something in the web.config or Umbraco config as I too had a similar issue but do not remember how I fixed it.
Anything you can remember would help.
Thanks
My Global.asax file looks like this:
<%@ Application CodeBehind="~/App_Code/global.asax.cs" Inherits="Global" Language="C#" %>
I m having same issue and also I m a little new to Umbraco. if i m correct in Umbraco 7 we don't have a global file. Is it ok if I add as Mark suggested ? will there be any issues ?
@Andy I have exectly same issue as you were facing. Can you please guide how you handled ? I have added event but on error its not being hit. Can you please help.
Yep, you can add a Global.asax, just make sure that the code file inherits the correct namespace, ie.
Then in the codebehind, something like:
Thanks for replying Andy. Its a great help and I highly appropriate this community support :)
cheers and have a great day.
Hey Haansi,
I have the same problem
Global.asax file:
<%@ Application Codebehind="Global.asax.cs" Inherits="Umbraco.Web.UmbracoApplication" Language="C#" %>
<script RunAt="server">
void Application_Error(object sender, EventArgs e)
{
// Code to get the error message and send me an e-mail with the details.
With every error, I get two identical error messages :/ What's happening?
Application_Error called twice
I am also running into the issue with the
Application_Error
function firing twice with identical exceptions - does anybody have any ideas?Application_Error called twice
I am working on a solution similar to Andy Neil's above -- but a dumb question for everyone -- with regard to the namespace / custom global class referred to in the Inherits="" attribute in Global.asax -- where should/does this class live? App_Code? I've got an override method I want to implement but i don't know where to put it!
Thanks, Garrett
I got the same problem here : Global.asax.cs / Application_Error gets called 2 times with the same exception.
Did anybody found out why ?
Thank you
Umbraco Version : 8.0.0
yw.
-OXEN
is working on a reply...