I have an application written in Csla using Mvc 3 and converted it to Mvc 4. I have a menu that displays items based on what role the user is in. Hmm, the link used to be: http://www.webpirates.nl/webpirates/robin-van-der-knaap/29-aspnet-mvc-site-map for the site map. This I combined with implementing membership and role provider at: http://brianlegg.com/post/2011/05/09/Implementing-your-own-RoleProvider-and-MembershipProvider-in-MVC-3.aspx and got a really cool treeview menu to work and the items displayed based on the role or roles the user was in and they were using Csla. Here is the code that works in Mvc 3, but does not work in Mvc 4:
public override bool IsAccessibleToUser(System.Web.HttpContext context, System.Web.SiteMapNode node) {
// If node has no roles specified means it is accessible (unless parent is not accessible)
if (node.Roles == null) {
return true;
}
// Iterate roles
foreach (string role in node.Roles) {
// If user is in role, node is accessible
if (Csla.ApplicationContext.User.IsInRole(role))
//if (context.User.IsInRole(role)) {
// Node is accessible
return true;
}
}
// Node is not accessible
return false;
}
The code is executing in LoadUser in my NWIdentity.cs code but somehow
base.Roles = new Csla.Core.MobileList<string>(data.Roles);
is not keeping the roles in the ApplicationContext.
Any ideas on how to upgrade to Mvc 4 would be most appreciated.
Keith
Copyright (c) Marimer LLC