N
Nathan Sokalski
When I call System.Web.Security.Roles.GetRolesForUser() it returns no
results (an array of length 0) even though I have roles associated with the
currently logged in user. I am able to get the username by calling
System.Web.Security.Membership.GetUser().UserName. Why am I unable to get
the Roles, and what could I need to change? The <membership> and
<roleManager> elements in my Web.config are as follows:
<membership defaultProvider="CustomizedProvider">
<providers>
<add name="CustomizedProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="logindb"
applicationName="Membership"
minRequiredPasswordLength="8"
minRequiredNonalphanumericCharacters="0"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"/>
</providers>
</membership>
<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
<providers>
<add name="CustomizedRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="logindb"
applicationName="Membership"/>
</providers>
</roleManager>
Everything that I have tried with Membership has given me no trouble, but
Roles seems to want to pretend that there are no roles, even though I have
added the roles using the ASP.NET Website Administration Tool, and even
looked directly at the database, so I know that the roles are there and are
associated with the users. Why am I able to use Membership but not Roles? I
would think that if there was a problem with the setup I would recieve an
Exception or error rather than just be returned an empty array. Any help
would be greatly appreciated. Thanks.
results (an array of length 0) even though I have roles associated with the
currently logged in user. I am able to get the username by calling
System.Web.Security.Membership.GetUser().UserName. Why am I unable to get
the Roles, and what could I need to change? The <membership> and
<roleManager> elements in my Web.config are as follows:
<membership defaultProvider="CustomizedProvider">
<providers>
<add name="CustomizedProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="logindb"
applicationName="Membership"
minRequiredPasswordLength="8"
minRequiredNonalphanumericCharacters="0"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"/>
</providers>
</membership>
<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
<providers>
<add name="CustomizedRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="logindb"
applicationName="Membership"/>
</providers>
</roleManager>
Everything that I have tried with Membership has given me no trouble, but
Roles seems to want to pretend that there are no roles, even though I have
added the roles using the ASP.NET Website Administration Tool, and even
looked directly at the database, so I know that the roles are there and are
associated with the users. Why am I able to use Membership but not Roles? I
would think that if there was a problem with the setup I would recieve an
Exception or error rather than just be returned an empty array. Any help
would be greatly appreciated. Thanks.