How to get rid of Windsor in Application_End other than its execution in HttpApplication.Dispose?

I have an ASP.NET MVC project where I am using Castle.Windsor. This is set in the Global.asax file and attached to the HttpApplication. Until recently, I disposed of the container in the Dispose method:

public override void Dispose()
{
    Container.Dispose();
    base.Dispose();
}

      

But when debugging over the past few days, I've noticed (usually the second time I start the VS.NET development server) I get this error:

The area has already been deleted. This is most likely a bug in the calling code.

I found vague references to the Castle-Project Google development team to call Container.Dispose () on Application_End instead. So I did it and now I don't seem to get any more errors ... at least until now.

I don't understand what is different. Are there situations where Dispose is called but Application_End is not? If so, how is this application still being used on the next request?

+3


source to share


1 answer


Are there situations where Dispose is called but Application_End is not?

Yes.

If so, how is this app still being used on the next request?



This is not true.

Asp.Net will create multiple instances of your HttpApplication derived class and use them to handle requests, but it will only call Application_Start and Application_End once, period.

+3


source







All Articles