In my ASP.NET MVC 3 application i have two types of users – regular users and admin users. Obviously the latter have greater privileges than the former. I have a page level authorization implementation in place, but for screen level items (show this button if admin, etc.) I would like to know what is the most appropriate solution to make a boolean IsAdmin flag available on all screens. I can think of a bunch of different methods cookies/session variables/httpcontext, but I’m wondering what is used with success in production. Any guidance is appreciated
Thanks in advance
JP
http://msdn.microsoft.com/en-us/library/system.web.httpcontext.user.aspx
HttpContext.Useris of typeIPrincipal, which has one methodIsInRole. If you are usingFormsAuthenticationyou’ll get this for free.HttpContext.Userwill be available directly from any view