ASP.NET MVC and role caching?

我只是一个虾纸丫 提交于 2019-12-23 04:56:50

问题


I am developing an ASP.NET MVC app with custom membership and role providers.

My custom role provider uses LinqToEntities to query the user/role mapping table and retrieve if a user is in a role or not.

When running on debug, local machine, everything is fine. When deploying on IIS7 however, I have this strange behavior:

When I change roles to a user, and then login with that user, it retains the old roles, instead of the new ones. It's like they are cached somewhere, but I already set the cacheRolesInCookie="false" option in the Web.config

Reading on the web, I saw that the option I mentioned is just a directive for the provider, meaning if I don't implement its usage, it will be ignored, is that right?

This leaves me puzzled. My provider should perform a fresh query every time a method is called. It works locally, but not on the deploy machine with IIS7.

Anyone knows if there's any hidden setting in IIS7 to make things work right?

Thanks.


回答1:


After a long time I found the solution.

The problem was residing on the EF context I was using to read the users/roles.

I fixed it resintantiating the context every time a role is checked, instead of keeping the same context until application restarted.



来源:https://stackoverflow.com/questions/1914437/asp-net-mvc-and-role-caching

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!