Sam....thanks for your suggestion on the IHttpModule Dispose, however I am
99% certain it is NOT being driven. I have even tried "throwing an
exception" in the Dispose....and NOTHING. Yet, I can force an application
recycling by changing the web.config....and I will see a new INIT being
driven when I do this.
Code follows...
using System;
using System.Web;
using System.Web.Hosting;
using System.Collections;
using System.Text;
using System.IO;
public class HttpModuleTrace : IHttpModule
{
~HttpModuleTrace()
{
TraceIt("Finalizer");
}
public void Init(HttpApplication application)
{
TraceIt("Init");
application.BeginRequest += (new
EventHandler(this.Application_BeginRequest));
application.EndRequest += (new
EventHandler(this.Application_EndRequest));
application.Disposed += (new EventHandler(this.Application_Disposed));
}
public void Dispose()
{
TraceIt("Dispose");
}
private void Application_BeginRequest(Object source, EventArgs e)
{
TraceIt("Application_BeginRequest");
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
context.Response.Write("<h1><font color=red>HelloWorldModule:
Beginning of Request</font></h1><hr>");
}
private void Application_EndRequest(Object source, EventArgs e)
{
TraceIt("Application_EndRequest");
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
context.Response.Write("<hr><h1><font color=red>HelloWorldModule:
End of Request</font></h1>");
}
private void Application_Disposed(Object source, EventArgs e)
{
TraceIt("Application_Disposed");
}
private string GetTraceFilePath()
{
System.Web.HttpContext http = System.Web.HttpContext.Current;
return http.Request.PhysicalApplicationPath + "HttpModuleTrace.txt";
}
private void TraceIt(string TraceText)
{
using (StreamWriter sw = new StreamWriter(GetTraceFilePath(), true,
System.Text.Encoding.UTF8))
{
sw.WriteLine(DateTime.Now.ToString("d-MMM-yyyy HH:mm:ss.fff") +
" - " + TraceText);
sw.Flush();
sw.Close();
}
}
}
--
Philip
"Samuel R. Neff" wrote:
>
How exactly are you tracing Dispose() ? Is it possible that Dispose()
is being called but whatever resources it's using to trace were
already disposed.
Sam
------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
On Fri, 18 May 2007 06:53:05 -0700, Philip
<ph****@softwareforever.comwrote:
When is the IHttpModule Dispose driven ?....at application recycle time ?
I developed a test HttpModule to trace INIT, BeginRequest, EndRequest and
Dispose....and the Dispose never gets driven. After a while the INIT is
redriven however the Dispose was never driven.
I am trying to locate the best means to hook ASP.NET application recycling
..... Is IHttpModule Dispose a solution for this and if so how ?...... or
should I use IRegisterObject ?.... I have seen some web postings on
IRegisterObject.