Click here to Skip to main content
15,900,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I was looking for set custom authentication I found we must set role to user
like this
Roles.AddRoleToUser(userName, RoleName)

and found that I must put configuration in my webconfig
<roleManager enabled="true" defaultProvider="DefaultRoleProvider">
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />

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?
Updated 10-Jan-16 21:33pm

1 solution


Please follow the below link:
Secure Applications Using Authentication and Authorization | The ASP.NET Site[^]
Here you can find the guide to implement in a proper way, Rles in MVC3.

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900