When will the ASP.NET controller be destroyed?

As per this answer ASP.NET MVC creates a new instance of the controller class to respond to every request.

My question is when is the controller instance destroyed?

So far, I have assumed (perhaps incorrectly) that these instances are destroyed at the end of each answer, but some of the database pooling issues I make me think could be left to the garbage collector. Does anyone know about this?

+3


source to share


1 answer


The controller remains cleaned up by the garbage collector. But if you were to send a new request before the old controller is cleaned up, it shouldn't affect your new request as a new new controller will be created for the new request.



If you are having problems with the DB, it might come from the way you handle reading / writing to the DB on your backend server. Context DB "A" is unaware of the changes occurring in another context B "B" if A was created before the changes in B. Not sure if this is the problem you are getting.

+6


source







All Articles