Instance members of an ActionFilter attribute is not thread safe – MVC
Posted by vivekcek on June 26, 2016
I was trying to inject a dependency to my filter attribute via Ninject’s property injection.The injected instance was using a database connection too.
And one of the ajax polling call was hitting this attribute every 10 seconds.
Strange i got some thread concurrency issue and site went down.
Later i found that in MVC for each request a controller is created, but for each request the same instance of filter attribute is reused.
You can test this via putting break points in the constructor of controller and attribute.
Advertisements
Leave a Reply