Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
private void context_PostRequestHandlerExecute(object sender, EventArgs e)
{
if(HandleCurrentResponse())
{
IHttpHandler handler = HttpContext.Current.Handler;
PageBase page = null;
if(handler is PageBase)
page = (PageBase)handler;
if(page != null)
{
EPiTrackerPage tracker = new EPiTrackerPage(page.CurrentPage);
tracker.SavePage();
}
}
}
private bool HandleCurrentResponse()
{
return HttpContext.Current.Response.StatusCode == 200;
}
This was the only event (as far as I know and tested) that had both the session and the handler objects available with correct data in it. The HandleCurrentResponse() method just checks the statuscode for the current request. I'm not interested in logging all 404 errors that pops up in a request (like missing images etc.). 200 = OK.
Also make sure to add the event handler in Init:
context.PostRequestHandlerExecute += new EventHandler(context_PostRequestHandlerExecute);
Thank you for your help!
Frank :)