ASP .NET自定义RoleProvider不重新检测cacheRolesInCookie =“true” [英] ASP .NET Custom RoleProvider not resepecting cacheRolesInCookie="true"

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

问题描述

我已经实现了一个自定义角色提供程序,并在我的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?

推荐答案

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不重新检测cacheRolesInCookie =“true”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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