After registration, the user is created and a role is assigned successfully. So then I added the attribute
[Authorize]
to the appropriate controllers and this works, bouncing anonymous users to the LogIn page as expected. However, when I add the roles filter, for example
[Authorize(Roles = "Venue")]
it again bounces to the login page, but, once you've logged in and it returns to the original, it throws the error
Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'.
I suspect it's the role provider entry in the web.config that's causing the problem, but I couldn't say how.
<roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider"><providers><clear/><add name="AspNetSqlRoleProvider" connectionStringName="DefaultConnection" applicationName ="MyApp" type="System.Web.Security.SqlRoleProvider" /></providers></roleManager>
EDIT:
I thought about trying it from another angle, I replaced the line
[Authorize(Roles = "Venue")]
with
[Authorize]
and then added
public ActionResult Index() { if (User.IsInRole("Venue")) { return RedirectToAction("index", "Venue"); } else if (User.IsInRole("Public")) { return RedirectToAction("index", "Public"); } else { return View(); } }
I get the same error, though instead of it appearing in the browser, VS2013 throws the exception instead. Is there a way round this?