I have a MVC API ActionFilterAttribute that does a permissions check using the Entity Framework. I’ve found that because of ActionFilterAttribute caching the EF connection is often broken. You can find other questions about here. So does anyone know how to prevent caching in ActionFilterAttributes?
I have a MVC API ActionFilterAttribute that does a permissions check using the Entity
Share
Just a Note to your title: I would say that Action Filters in MVC are not cached, they act as singletons (as explained in the link you’ve provided).
As the answer to your needs I would say use Request based persistence. Because you would most likely want to do some stuff like:
– OnActionExecuting() (e.g. open Transaction)
– OnActionExecuted() (commit or rollback)
So put your object (_unitOfWork) into
You can access it form the singleton methods, while operating on request dependent objects. I am doing it similar way with NHibernate Session