umbracoApplication.Error not firing if exception accure in MVC ?
If my understanding is correct with Umbraco 7 we can't have global.asax file. I have to handle asp.net's application error event and log errors. I follow this link and hock umbracoApplication.Error event.
Issue is, on error this event is not firing. When I run application I can see umbracoApplication.Error is regestered but throwing an error in MVC action do not come here. Please help me.
My MVCStartup.cs is below:
public class MyStartupHandler : IApplicationEventHandler
{
public void OnApplicationStarted(
UmbracoApplicationBase umbracoApplication,
ApplicationContext applicationContext)
{
//Create a custom route
RouteTable.Routes.MapRoute(
"HealthInsurance",
"HealthInsurance/{action}/{id}",
new
{
controller = "HealthInsurance",
id = UrlParameter.Optional
});
RouteTable.Routes.MapRoute(
"HomeLoan",
"HomeLoan/{action}/{id}",
new
{
controller = "HomeLoan",
id = UrlParameter.Optional
});
RouteTable.Routes.MapRoute(
"LifeInsurance",
"LifeInsurance/{action}/{id}",
new
{
controller = "LifeInsurance",
action = "Index",
id = UrlParameter.Optional
});
RouteTable.Routes.MapRoute(
"EDM",
"EDM/{action}/{id}",
new
{
controller = "EDM",
action = "Index",
id = UrlParameter.Optional
});
RouteTable.Routes.MapRoute(
"AFFILIATE",
"AFFILIATE/{action}/{id}",
new
{
controller = "AFFILIATE",
action = "Index",
id = UrlParameter.Optional
});
RouteTable.Routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new
{
// controller = "Home",
action = "Index",
id = UrlParameter.Optional
}
);
}
void umbracoApplication_Error(object sender, System.EventArgs e)
{
throw new Exception("Test MVc Umbraco Error");
}
public void OnApplicationInitialized(
UmbracoApplicationBase umbracoApplication,
ApplicationContext applicationContext)
{
}
public void OnApplicationStarting(
UmbracoApplicationBase umbracoApplication,
ApplicationContext applicationContext)
{
umbracoApplication.Error += umbracoApplication_Error;
}
}
My Global.asax file has only below line but no Codebehind class is there.
public class LandingController : Umbraco.Web.Mvc.RenderMvcController
{
[OutputCache(Duration=300)]
public ActionResult uLanding(Landing model)
{
throw new Exception();
return base.Index(model);
}
}
umbracoApplication.Error not firing if exception accure in MVC ?
If my understanding is correct with Umbraco 7 we can't have global.asax file. I have to handle asp.net's application error event and log errors. I follow this link and hock umbracoApplication.Error event.
Issue is, on error this event is not firing. When I run application I can see umbracoApplication.Error is regestered but throwing an error in MVC action do not come here. Please help me.
My MVCStartup.cs is below:
My Global.asax file has only below line but no Codebehind class is there.
<%@ Application Codebehind="Global.asax.cs" Inherits="Umbraco.Web.UmbracoApplication" Language="C#" %>
Controller & Action is below:
is working on a reply...