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
感谢
它在实时服务器上工作,所以这很奇怪。我猜它已经解决了。