ASP .NET自定义RoleProvider不resepecting cacheRolesInCookie ="真" [英] ASP .NET Custom RoleProvider not resepecting cacheRolesInCookie="true"

查看:333
本文介绍了ASP .NET自定义RoleProvider不resepecting cacheRolesInCookie ="真"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了自定义角色提供程序,并在我的web.config文件中配置这样的:

I've implemented a custom role provider, and configured it in my web.config file like this:

<roleManager enabled="true" defaultProvider="TDRoleProvider" cacheRolesInCookie="true">
  <providers>
    <clear/>
    <add name="TDRoleProvider" type="TDRoleProvider"/>
  </providers>
</roleManager>

我已经覆盖了GetRolesForUser功能在我的自定义角色提供程序,我已经走进它,它工作得很好 - 负载高达60角色我与测试用户。不过,我已经注意到,GetRolesForUser被调用的每个调用User.IsInRole请求。在我写的其他应用程序,它只是调用它一次,然后高速缓存结果在cookie中。出于某种原因,缓存是不工作的这个程序。任何想法,为什么?

I've overridden the GetRolesForUser function in my custom role provider, and I've stepped into it, and it works just fine - loads up 60 roles for the user I'm testing with. However, I've noticed that the GetRolesForUser gets called on every request that calls User.IsInRole. In other apps I've written, it only calls it once, then caches the result in the cookie. For some reason, the caching is not working for this app. Any ideas as to why?

推荐答案

<一个href=\"http://connect.microsoft.com/VisualStudio/feedback/details/104688/rolemanager-cacherolesincookie-option-does-not-work\" rel=\"nofollow\">http://connect.microsoft.com/VisualStudio/feedback/details/104688/rolemanager-cacherolesincookie-option-does-not-work

时,缓存(或不缓存)在RolePrincipal问题通过一些设计迭代的去了,我们最后只由IPrincipal接口(即IsInRole)公开的方法缓存解决。

"The issue of when to cache (or not cache) in RolePrincipal went through a number of design iterations, and we finally settled on only caching for the method exposed by the IPrincipal interface (i.e. IsInRole). "

这篇关于ASP .NET自定义RoleProvider不resepecting cacheRolesInCookie =&QUOT;真&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆