I have a requirement in my MVC application to present the user with a different view of an action based on their role. What is the best way to do this?
Currently I have the following code which I do not like:
if (HttpContext.User.IsInRole("Admin"))
return View("Details.Admin", model);
else if (HttpContext.User.IsInRole("Power"))
return View("Details.Power", model);
//default
return View("Details", model);
Would this be a good fit for an Action Filter?
Absolutely:
Or you could even build a custom view engine.