API Questions on Kentico API.
Version 6.x > API > Application_Error firing twice View modes: 
User avatar
Member
Member
mark-wiseman.net - 12/13/2011 7:20:50 PM
   
Application_Error firing twice
Hi i am using Kentico 6.0

I need to configure it to use log4net.
When i open Global.asax.cs and this code Application_Error is fired twice.


public void Application_Error(object sender, EventArgs e)
{
base.Application_Error(sender, e);

Exception ex = Server.GetLastError().GetBaseException();
Logging.PutError(string.Empty, ex);
}

What am i doing wrong?
Thanks

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/13/2011 10:02:20 PM
   
RE:Application_Error firing twice
Hi,

Could you please explain what exactly and where are you doing first so we can tell what is wrong or how to achieve it?

Thank you.

Best regards,
Juraj Ondrus

User avatar
Member
Member
mark-wiseman - 12/13/2011 10:10:45 PM
   
RE:Application_Error firing twice
I need to log/email un-handled exceptions.
I have created a test page.
In that page's Page_Load event I am just throwing a new exception (to test my logging)

In my App_Code/Global.asax.cs file I have added the function I mentioned above.

Is that clear enough?
I appreciate the help.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/19/2011 2:11:48 AM
   
RE:Application_Error firing twice
Hi,

What is your exact version number? In v6 the code from global.asax.cs file was moved to \App_Code\Application\CMSAppBase.cs so, I am little bit confused.

However, it is possible that the code will be fired more times - it depends on the IIS setting (e.g. <modules runAllManagedModulesForAllRequests="true">) but even though you will disable the managed modules, the AXD and other files can hit that code too. You need to add a condition where you will check the requested URL to filter out only what you need.

Best regards,
Juraj Ondrus

User avatar
Member
Member
mark-wiseman - 1/5/2012 11:03:20 PM
   
RE:Application_Error firing twice
I got it to work.

I deleted the code i put into Application_Error in Global.asax.cs and moved it to CMSAppBase.LogLastApplicationError()

This isn't my ideal solution because i was hoping to keep my code separate from kentico's code