本文介绍了如何在asp.net mvc3中设置角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在寻找设置自定义身份验证我发现我们必须为用户设置角色
喜欢这个
Hi,
I was looking for set custom authentication I found we must set role to user
like this
Roles.AddRoleToUser(userName, RoleName)
发现我必须在我的webconfig中配置
and found that I must put configuration in my webconfig
<roleManager enabled="true" defaultProvider="DefaultRoleProvider">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
但是在webconfig中添加这些行时运行应用程序时出现配置错误!
并从webconfig中删除roleManager
并尝试向用户添加角色
我得到了
but I have Configuration Error when run application when add those lines in webconfig!
and when remove roleManager from webconfig
and try to add role to user
I got
Unable to connect to SQL Server database
任何帮助?
any help?
推荐答案
这篇关于如何在asp.net mvc3中设置角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!