ASP.NET MVC Actions that return different views, or just make a ton of Actions?
- by Nate Bross
So, I am in a situation, where I need to display a different view based on the "Role" that the authenticated user has.
I'm wondering which approach is best here:
[Authorize(Roles="Admin")]
public ActionResult AdminList(int? divID, int? subDivID) 
{
    var data = GetListItems(divID.Value, subDivID.Value);
    return View(data);
}
[Authorize(Roles = "Consultant")]
public ActionResult ConsultantList(int? divID, int? subDivID)
{
    var data = GetListItems(divID.Value, subDivID.Value);
    return View(data);
}            
or should I do something like this
[Authorize]
public ActionResult List(int? divID, int? subDivID)
{
    var data = GetListItems(divID.Value, subDivID.Value);
    if(HttpContenxt.User.IsInRole("Admin") 
    { return View("AdminList", data ); }
    if(HttpContenxt.User.IsInRole("Consultant") 
    { return View("ConsultantList", data ); }
    return View("NotFound");
}