Question

Creating a Web App using ASP.NET MVC3, essential framework includes NHibernate (Fluent), Ninject, Razor, Automapper, Jquery, Rhino-Security.

Need to decide upon State Management Stratety (Session and Cache level). I have heard of following caching types,

  1. Output Cache
  2. Donut (Hole) Caching
  3. Data Caching

Considering a general scenario, I want to understand State Management policy to be used during a request,

LOGIN

  1. User goes to site, is still Unauthenticated, so redireted to Login page by FormsAuth module (QUESTION - As Login page is no user specific, definitely a candidate for Output Cache. But then the View is pure HTML flushed verbatim by MVC, so any benefit by using cache)

PAGE ACCESS

  1. As I am using Rhino Security, navigation depends on Permissions assigned to individal User. Each user MAY HAVE specific permissions assigned BUT most of users would have permissions as assigned to UseGroup to which that user belongs. Navigation creation is so a two step process - Fetching permission set for user and Gernerating Navigation UI and so here are my two Qs (QUESTION 1 - Permission for current user would be required at each page access for action authorization as well as navigation cretion, so where to store it - Session? QUESTION 2 - Navigation too MAY be created for each user for first access and stored in session, BUT we are aware it would be same for each user in a UserGroup unless given specific ones. So, we may create Hash for a certain set of permissions and then either save Navigation to Data Cache OR enable Output Cache using VarByCustom on Child action responsible for creating Nav UI)

I see i have been too verbose. In fact i do have more Questions, but let me see first if smbdy really bothers to read this much crap here

No correct solution

OTHER TIPS

Regarding User Permissions, given they are the same for each User Group, I would store them in Cache like this:

if (System.Web.HttpContext.Current.Cache["UserGroup_1_Permissions"] == null)
{
    _Permissions = DAL.getPermissions("UserGroup1") as List<Permissions>;
    System.Web.HttpContext.Current.Cache["UserGroup_1_Permissions"] = _Permissions;
}
else
{
    _Permissions = System.Web.HttpContext.Current.Cache["UserGroup_1_Permissions"] as List<Permissions>;
}

This way, you would retrieve them from DB only first time, as it will get stored in HttpContext.Current.Cache.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top