I'm trying to assign user to a role in asp.net membership.
protected void btnAssignUser_Click(object sender, EventArgs e)
{
Roles.AddUserToRole("Upendra", "Admin");
}
but I'm keep getting the error below.
The user 'Upendra' was not found.
However, 'Upendra' user does does exists in the Users table and also the 'Admin' role in the Roles table.
My web.config settings are as follows
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=IROSHEN-PC;Initial Catalog=IndunilaDB;Integrated Security=true;" />
</connectionStrings>
<profile defaultProvider="DefaultProfileProvider">
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</profile>
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<roleManager enabled="true" cacheRolesInCookie="true" cookieName=".ASPXROLES"
cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true"
cookieProtection="All" defaultProvider="DefaultRoleProvider" createPersistentCookie="false"
maxCachedResults="25">
<providers>
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="IndunillaWeb" />
</providers>
</roleManager>