我的 ASP.net 通用成员的默认角色提供程序没有创建缓存角色的 cookie。有任何想法吗
<roleManager enabled="true" createPersistentCookie="true" cacheRolesInCookie="true" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" defaultProvider="DefaultRoleProvider" >
<providers>
<clear />
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</roleManager>
我正在使用带有 AuthorizeAttributes 的 MVC,并且每次检查角色级别时都会命中数据库。cookie .asproles 似乎没有被创建。
MiniProfiler 显示
ExecuteStoreCommands Execute GetResults System.Collections.Generic.IEnumerable<T>.GetEnumerator GetRolesNamesForUser GetRolesForUser
DECLARE @appName nvarchar = N'/',
@userName nvarchar = N'TestUser'
SELECT
[Project1].[RoleName] AS [RoleName]
FROM ( SELECT
[Extent2].[RoleName] AS [RoleName]
FROM [dbo].[Users] AS [Extent1]
CROSS JOIN [dbo].[Roles] AS [Extent2]
INNER JOIN [dbo].[Applications] AS [Extent3] ON [Extent3].[ApplicationId] = [Extent2].[ApplicationId]
INNER JOIN [dbo].[UsersInRoles] AS [Extent4] ON ([Extent1].[UserId] = [Extent4].[UserId]) AND ([Extent4].[RoleId] = [Extent2].[RoleId])
WHERE ((LOWER([Extent3].[ApplicationName])) = @appName) AND ((LOWER([Extent1].[UserName])) = @userName)
) AS [Project1]
ORDER BY [Project1].[RoleName] ASC
谢谢