I cannot get Ninject to delete objects in the request area in an ASP.NET MVC application with a web API no matter what I do.
What am I doing:
- Create a new ASP.NET web application with Visual Studio 2013. I select the MVC template and add the web API to it (it also has the ASP.NET identifier in the default package)
- I install the Ninject.MVC5 package via nuget (install-package Ninject.MVC5)
I add the following class to my class:
public class SomeDisposable: IDisposable {public void Dispose () {System.Diagnostics.Debug.WriteLine ("test"); }}
I add the following binding to the NinjectWebCommon RegisterServices method
kernel.Bind () ToSelf () InRequestScope (); ..
I am adding an object of type SomeDisposable to the Home controller
public HomeController (SomeDisposable some) {}
I launch the application and put a breakpoint in the HomeController constructor and the Dispose method of the SomeDisposable class. The controller receives the object (presumably from Ninject), the page loads, but the Dispose method is never called .
At this point, everything is already broken, but I add the web API controller, install Ninject.WebApi and repeat the experiment with the WebAPI controller, and I get the same result.
, - Ninject Dispose Ninject https://github.com/ninject/Ninject.Web.Common/wiki/InRequestScope, , - , Ninject.Web.Common OnePerRequestHttpModule (, ), , . PerRequest web.config , , .
. , , OWIN - , , , . ?