Hi,
I am new to MVC and I am trying to add a user to a role after login.
I have managed to use the AuthorizeRoles on actions in a controller but when trying to add a user to a like as per the below code I get an error saying User Not Found.
System.Web.Security.Roles.AddUsersToRole(new string[] { httpContext.User.Identity.Name }, roles);
The Users Table in my database is as follows:
[Id]
,[FirstName]
,[LastName]
,[EmailAddress]
,[UserName]
,[Password]
,[DateCreated]
,[Gender]
,[ApplicationId]
,[IsAnonymous]
,[LastActivityDate]
,[UserId]
I have tried passing through the UserName, UserId and email address of any user but it keeps telling me user not found for any user that has been logged in.
In my web.config I am using the below configuration in System.Web:
<rolemanager enabled="true" defaultprovider="SqlRoleProvider">
<providers>
<clear>
<add name="SqlRoleProvider">
connectionStringName="RolesCon"
applicationName="/"
type="System.Web.Providers.DefaultRoleProvider"/>
Has anyone else experienced this type of an issue?
What I have tried:
Searched Google, added rolemanager to the web.config file.