The event handler lives the whole life of your application, so you need to add it only after you do not add it every request. The event itself will trigger each request, and only one handler will be called each time the event is raised.
Add it to Application_Start in global.asax, not Application_BeginRequest , or better, create an HTTP module instead.
Also, I think you might not even need an event handler . A method with the current name will be called by convention, similar to the Page / Control AutoEventWireup parameter (for example, Page_Load). Note that this may have problems in ASP.NET MVC applications, as some people report. So my suggestion is to rename the function, add an event handler to Application_Start or better in the new HTTP module that you are creating .
Meligy
source share