G
Guest
Can anyone please tell me why the following doesn't work...
using System;
using System.Web;
namespace AspTests
{
public class Test : System.Web.UI.Page
{
override protected void OnInit(EventArgs e)
{
System.Diagnostics.Trace.WriteLine( "Test.OnInit()" );
HttpContext.Current.ApplicationInstance.EndRequest += new
EventHandler(ApplicationInstance_EndRequest);
base.OnInit(e);
}
private void ApplicationInstance_EndRequest(object sender, EventArgs e)
{
System.Diagnostics.Trace.WriteLine(
"Test.ApplicationInstance_EndRequest()" );
}
}
}
When I run that code my ApplicationInstance_EndRequest is never called.
However, when I modify the Global.asax to include the following code...
protected void Application_EndRequest(Object sender, EventArgs e)
{
System.Diagnostics.Trace.WriteLine(
"Global.ApplicationInstance_EndRequest()" );
}
That code is called! Any clue why the HttpApplication won't fire my event
handler but it will fire the one defined in Global.asax, which I can only
assume is wired the same way I did mine?
using System;
using System.Web;
namespace AspTests
{
public class Test : System.Web.UI.Page
{
override protected void OnInit(EventArgs e)
{
System.Diagnostics.Trace.WriteLine( "Test.OnInit()" );
HttpContext.Current.ApplicationInstance.EndRequest += new
EventHandler(ApplicationInstance_EndRequest);
base.OnInit(e);
}
private void ApplicationInstance_EndRequest(object sender, EventArgs e)
{
System.Diagnostics.Trace.WriteLine(
"Test.ApplicationInstance_EndRequest()" );
}
}
}
When I run that code my ApplicationInstance_EndRequest is never called.
However, when I modify the Global.asax to include the following code...
protected void Application_EndRequest(Object sender, EventArgs e)
{
System.Diagnostics.Trace.WriteLine(
"Global.ApplicationInstance_EndRequest()" );
}
That code is called! Any clue why the HttpApplication won't fire my event
handler but it will fire the one defined in Global.asax, which I can only
assume is wired the same way I did mine?