Azure Membership Roles and MVC
I am developing an ASP.NET MVC3 website and I am using Microsoft ASP.NET generic providers. Web.config:
<connectionStrings>
<add name="MyContext" connectionString="data source=tcp:***.database.windows.net,1433;Initial Catalog=***;User Id=***;Password=***;Trusted_Connection=False;Encrypt=True;Connection Timeout=30" providerName="System.Data.SqlClient" />
</connectionStrings>
...
<roleManager defaultProvider="DefaultRoleProvider" enabled="true">
<providers>
<clear />
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider" connectionStringName="MyContext" applicationName="/" />
</providers>
</roleManager>
Azure has connection strings. I added Aspnet tables and stored procedures using a request script. Data in tables added by migrations. I checked it out on the management portal. I can get the profile memberships and profile details, but the code below is returning an empty list.
var userName = User.Identity.Name;
var userRoles = Roles.GetRolesForUser(userName).ToList();
userName is correct, and the aspnet_UsersInRoles table also contains correct data. There are no exceptions on the page. Why is userRoles empty?
+3
source to share